/**
 * zy 公共方法
 */
 function UtilFn() {
    return Util = {
        stopEvent: function (event) { //阻止冒泡事件
            //取消事件冒泡
            var e = arguments.callee.caller.arguments[0] || event; //若省略此句，下面的e改为event，IE运行可以，但是其他浏览器就不兼容
            if (e && e.stopPropagation) {
                // this code is for Mozilla and Opera
                e.stopPropagation();
            } else if (window.event) {
                // this code is for IE
                window.event.cancelBubble = true;
            }
        },
        //半年前时间值
        GetPastHalfYear: function (data) {
            var seperator1 = "-";
            var cur = "";
            if (!!data) {
                cur = new Date(data).getTime();
            } else {
                cur = new Date().getTime();
            }
            //将半年的时间单位转换成时间戳
            var half = "";
            var year = new Date(cur).getFullYear();
            if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
                half = 366 / 2 * 24 * 3600 * 1000;
            } else {
                half = 365 / 2 * 24 * 3600 * 1000;
            }
            var past = cur - half;//半年前的时间
            var pastDate = new Date(past);
            var pastYear = pastDate.getFullYear();
            var pastMonth = pastDate.getMonth() + 1;
            var pastDay = pastDate.getDate();
            if (pastMonth >= 1 && pastMonth <= 9) {
                pastMonth = "0" + pastMonth;
            }
            if (pastDay >= 0 && pastDay <= 9) {
                pastDay = "0" + pastDay;
            }
            return pastYear + seperator1 + pastMonth + seperator1 + pastDay;
        },
        // 获取时分秒
        GetNowFormatTime(mins, hasYMR, seperator) {
            var seperator1 = seperator || '-';
            if (!!mins || mins === 0) {
                var date = new Date();     //1. js获取当前时间
                var min = date.getMinutes();  //2. 获取当前分钟
                date.setMinutes(min + mins);  //3. 设置当前时间+10分钟：把当前分钟数+10后的值重新设置为date对象的分钟数
                var y = date.getFullYear();
                var m = (date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : (date.getMonth() + 1);
                var d = date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate();
                var h = date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours()
                var f = date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes()
                var s = date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds()
                // var formatdate = y+'-'+m+'-'+d + " " + h + ":" + f + ":" + s;
                var formatdate = "";
                if (hasYMR) {
                    formatdate = y + seperator1 + m + seperator1 + d + " " + h + ":" + f + ":" + s;
                } else {
                    formatdate = h + ":" + f + ":" + s;
                }
                console.log(formatdate) // 获取10分钟后的时间，格式为yyyy-mm-dd h:f:s
                return formatdate;
            }
            //当前时间
            return new Date().format("hh:mm:ss")
        },
        //当前时间
        GetNowFormatDate(seperator) {
            var date = new Date();
            var seperator1 = seperator || "-";
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        },
        // 获取上个月
        GetLastMonth(initDate) {
            let date = initDate ? new Date(initDate) : new Date();
            let year = date.getFullYear();
            let month = date.getMonth();
            if (month == 0) {
                year -= 1;
                month = 12;
            }
            return year + '-' + (month < 10 ? '0' + month : month);
        },
        //过去一年的时间
        GetPassYearFormatDate() {
            var nowDate = new Date();
            var date = new Date(nowDate);
            date.setDate(date.getDate() - 365);
            var seperator1 = "-";
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = year + seperator1 + month + seperator1 + strDate;
            return currentdate;
        },
        /**
         * 计算两个日期间天数 
         * Detedifference("2020-08-13 09:00:00","2020-08-13 09:31:00",true);0.5166666666666667
         *  */
        Detedifference(sDate1, sDate2, hasH) {
            var dateSpan, iDays, iHours;
            sDate1 = Date.parse(sDate1);
            sDate2 = Date.parse(sDate2);
            dateSpan = Math.abs(sDate2 - sDate1);
            iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
            iHours = dateSpan / (3600 * 1000);
            if (!hasH || (hasH === 'false')) {
                return iDays;
            }
            return (iHours % 0.5) > 0 ? iHours.toFixed(3) : iHours;
        },
        //计算某个日期前后几天的日期
        FunDateCalcu(date, num, hasHIS) {
            num = num || 0;
            var odate = new Date(date);
            odate = odate.valueOf();
            odate = odate - num * (24 * 3600 * 1000);
            odate = new Date(odate);
            var y = odate.getFullYear(),
                m = (odate.getMonth() + 1) < 10 ? "0" + (odate.getMonth() + 1) : (odate.getMonth() + 1),
                d = odate.getDate() < 10 ? "0" + odate.getDate() : odate.getDate();
            h = odate.getHours() < 10 ? "0" + odate.getHours() : odate.getHours();
            i = odate.getMinutes() < 10 ? "0" + odate.getMinutes() : odate.getMinutes();
            s = odate.getSeconds() < 10 ? "0" + odate.getSeconds() : odate.getSeconds();
            if (!hasHIS || (hasHIS === 'false')) {
                return y + "-" + m + "-" + d;
            }
            return y + "-" + m + "-" + d + ' ' + h + ':' + i + ':' + s;
        },
        //获取当前时间的前后时间 如一周前
        FunDate(aa) {
            var date1 = new Date(), time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();//time1表示当前时间
            var date2 = new Date(date1);
            date2.setDate(date1.getDate() + aa);
            var month = date2.getMonth() + 1;
            var strDate = date2.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }

            var time2 = date2.getFullYear() + "-" + month + "-" + strDate;
            return time2;
        },
        FormatTrueOrFalse(value, row, index) {
            if (value == '0') {
                return '否';
            } else {
                return '是';
            }
        },
        //0显示数字
        FormatNumberToString(value, row, index) {
            return value + '';
        },
        //百分号
        FormatNumberToPercent(value, row, index) {
            return value + '%';
        },
        //两位小数，百分号
        FormatFixedAndPercent(value, row, index) {
            return Number(value).toFixed(2) + '%';
        },
        //百分比格式化
        FormatPercent(value) {
            if (value <= 1) {
                return (value * 100).toFixed(2) + "%";
            } else {
                return value.toFixed(2) + "%";
            }
        },
        //百分比格式化
        FormatPercent100(value, row, index) {
            return (Number(value) * 100).toFixed(2) + "%";
        },
        //千分位数字 不补小数位
        FormatThousandDirect(val) {
            if (isNaN(Number(val)) || val == 0) {
                return val;
            }
            let res = val.toString().replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
            if (res.indexOf(".") != -1) {
                res = res.split(".")[0] + "." + res.split(".")[1].replace(/\,/g, "");
            }
            return res;
        },
        //千分位数字 2位小数
        FormatThousand(val, row, index) {
            if (!val && typeof (val) === "object") {//null
                return "--";
            }
            if (val != 0 && typeof (val) != 'string') {
                val = val.toFixed(2).toString().replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
                if (val.indexOf(".") == -1) {
                    return val + '.00';
                } else {
                    if (val.split(".")[1].length == 1) {
                        return val + "0";
                    } else {
                        return val;
                    }
                }
            } else {
                return Number(val).toFixed(2).toString().replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
            }
        },
        //千分位数字 4位小数
        FormatThousandFour(val, row, index) {
            val = val + "";
            if (val != 0) {
                if (val.indexOf(".") != -1) {
                    val = Number(val).toFixed(4);
                    var valFixed = val.substring(val.indexOf("."));
                    var valFm = val.replace(valFixed, "");
                    return valFm.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,') + valFixed;
                } else {
                    return val.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,') + '.0000';
                }
            } else {
                return Number(val).toFixed(4);
            }
        },
        //表格内容省略为空
        FormatterEllipsisNull: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}'> </p>`;
        },
        //表格内容省略为空左对齐
        FormatterEllipsisLeftNull: function (value, row, index) {
            return value || value === 0 ? "<p class='ellipsis_p' title='" + value + "'>" + value + "</p>"
                :
                "<p class='ellipsis_p' > </p>";
        },
        //表格内容省略
        FormatterEllipsis: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--'>--</p>`;
        },
        //表格内容省略左对齐
        FormatterEllipsisLeft: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}' style='text-align:left;'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--' style='text-align:left;'>--</p>`;
        },
        //表格内容省略右对齐
        FormatterEllipsisRight: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}' style='text-align:right;'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--' style='text-align:right;'>--</p>`;
        },
        //表格内容省略
        FormatterEllipsisYellow: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}' style='color:#C3891E;cursor: pointer;'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--' style='color:#C3891E;cursor: pointer;'>--</p>`;
        },
        //表格内容省略左对齐
        FormatterEllipsisLeftYellow: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}' style='text-align:left;color:#C3891E;cursor: pointer;'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--' style='text-align:left;color:#C3891E;cursor: pointer;'>--</p>`;
        },
        //表格内容省略 红色
        FormatterEllipsisRed: function (value, row, index, field) {
            return value || value === 0 ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}' style='color:#D13C3C;cursor: pointer;'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--' style='color:#D13C3C;cursor: pointer;'>--</p>`;
        },
        //表格内容省略
        FormatterEllipsisBlue: function (value, row, index) {
            return value || value === 0 ? "<p class='ellipsis_p' title='" + value + "' style='color:#1160B7;'>" + value + "</p>"
                :
                "<p class='ellipsis_p' title='--' style='color:#1160B7;'>--</p>";
        },
        //表格内容省略左对齐
        FormatterEllipsisLeftBlue: function (value, row, index) {
            return value || value === 0 ? "<p class='ellipsis_p' title='" + value + "' style='text-align:left;color:#1160B7;'>" + value + "</p>"
                :
                "<p class='ellipsis_p' title='--' style='text-align:left;color:#1160B7;'>--</p>";
        },
        //表格内容省略 生日
        FormatterEllipsisYMD: function (value, row, index, field) {
            // value = !!value ? value.slice(0,10).replace(/\//g,"-") : value;
            value = !!value ? new Date(value).format("yyyy-MM-dd") : value;
            return value ? `<p class='ellipsis_p ${field ? field : ""}' title='${value}'>${value}</p>`
                :
                `<p class='ellipsis_p ${field ? field : ""}' title='--'>--</p>`;
        },
        //底部页面切换样式处理
        FormatterBottomPage: function () {
            $(".page-list").remove();
            $(".page-jump-to input").removeClass("form-control").addClass("page_jump_style").next("button").removeClass("btn btn-default").addClass("page_button_style");
        },
        //移除底部不必要的内容
        removeBottomText: function (table) {
            var table = table ? table : "table.table";
            $(table).parents(".bootstrap-table").find(".page-list").remove();
            if (!!$(table).parents(".bootstrap-table").find(" .pagination-info").html()) {
                let text = $(table).parents(".bootstrap-table").find(" .pagination-info").html().split("，");
                $(table).parents(".bootstrap-table").find(" .pagination-info").html(text[1]);
                $(".page-jump-to input").removeClass("form-control").addClass("page_jump_style").next("button").removeClass("btn btn-default").addClass("page_button_style");
            }
        },
        /**
         * 校验查询传参的值 没有就不传参
         * @param {*传参键} Key 
         * @param {*传参值} value 
         * @param {*查询json} QueryJson 
         */
        TestQueryValue: function (Key, value, QueryJson) {
            // 有可能是int型所以要包含0的情况
            if (value || value === 0) {
                QueryJson[Key] = value;
            } else {
                delete QueryJson[Key];
            }
        },
        // 传参校验 是否选择id
        NoSelectId: function (Dom, key) {
            key = key || 'selectid';
            return Dom[0].dataset[key] == "00" ? "" : Dom[0].dataset[key];
        },
        // 传参校验 是否选择选项集合 int型
        NoSelectIdInt: function (Dom, key) {
            key = key || 'selectid';
            return Dom[0].dataset[key] == "00" ? null : Number(Dom[0].dataset[key]);
        },
        IsEnabledFn: function (Dom, key) {
            key = key || 'selectid';
            return Dom[0].dataset[key] == "true" ? true : false;
        },
        IsNull: function (obj, key) {
            return !!obj[key] ? obj[key] : "--";
        },
        //有值取值 无值为空
        IsNullValue: function (value, defaultV) {
            return !!value ? value : ((!!defaultV || defaultV === 0) ? defaultV : "");
        },
        //计算百分比
        GetPercent(curNum, totalNum, fixedNum) {
            // 默认呢保留两位小数
            fixedNum = fixedNum || fixedNum === 0 ? fixedNum : 2;
            curNum = parseFloat(curNum);
            totalNum = parseFloat(totalNum);
            if (isNaN(curNum) || isNaN(totalNum)) {
                return '-'
            }
            return totalNum <= 0 ?
                (fixedNum || fixedNum === 0 ? '0%' : '0.00%')
                :
                ((curNum * 100 / totalNum).toFixed(fixedNum) + '%');
        },
        //随机生成guid
        GetCrmfiletempid() {
            return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
                return v.toString(16);
            });
        },
        // 男女
        FormatterSex: function (value, row, index) {
            if (value == 1) {
                return "男";
            } else if (value == 2) {
                return "女";
            } else {
                return "--";
            }
        },
        //是否离职
        FormatterIsLeft: function (value, row, index) {
            if (value == 1) {
                return "是";
            } else if (value == 2) {
                return "否";
            } else {
                return "--";
            }
        },
        //条状黄色字体样式left
        FormatterGoPageLeft: function (value, row, index) {
            return "<p class='ellipsis_p' title='" + value + "' style='text-align:left;'><span class='openUrl'>" + value + "</span></p>";
        },
        //千分位后溢出省略 不判断小数位
        FormatterEllipsisThousandDirect: function (val, row, index) {
            if (!!val) {
                return Util.FormatterEllipsis(Util.FormatThousandDirect(val), row, index);
            }
            return "0";
        },
        //千分位后溢出省略
        FormatterEllipsisThousand: function (val, row, index) {
            if (!!val) {
                return Util.FormatterEllipsis(Util.FormatThousand(val), row, index);
            }
            return Number(val) === 0 ? "0.00" : val;
        },
        //千分位后溢出省略 四位小数
        FormatterEllipsisThousandFour: function (val, row, index) {
            if (!!val) {
                return Util.FormatterEllipsis(Util.FormatThousandFour(val), row, index);
            }
            return Number(val) === 0 ? "0.0000" : val;
        },
        //千分位后溢出省略 四位小数 元-亿
        FormatterEllipsisThousandFourYI: function (val, row, index) {
            if (!!val) {
                return Util.FormatterEllipsis(Util.FormatThousandFour(val / 100000000), row, index);
            }
            return Number(val) === 0 ? "0.0000" : val;
        },
        //千分位后溢出省略 四位小数 元-万
        FormatterEllipsisThousandFourWAN: function (val, row, index) {
            if (!!val) {
                return Util.FormatterEllipsis(Util.FormatThousandFour(val / 10000), row, index);
            }
            return Number(val) === 0 ? "0.0000" : val;
        },
        // init form_msg下的droupdown
        InitDroupDownDom: function (parentDom) {
            parentDom = parentDom || '.form_msg';
            //点击显示下拉框
            $(`${parentDom}`).on("click", ".dropdown_input", function () {
                if ($(this).parents(".dropdown_box").hasClass("readonly")) {//禁用下拉
                    return;
                }
                let menuToggle = $(this).find("i").hasClass("iconshangjiantou");
                if (menuToggle) {
                    $(this).find("i").removeClass("iconshangjiantou").addClass("iconxiajiantou");
                    $(this).siblings().hide();
                } else {
                    var checkIdArr = $(this).find(".dropdown_value").attr("data-selectid").split(","),
                        checkValueArr = $(this).find(".dropdown_value").html().split(";");
                    // 已选项高亮
                    if ($(this).next().hasClass("dropdown_menu_hascheck")) {//既有单选 又有多选
                        var curLiDom = $(this).next().children("li");
                        for (let j = 0; j < checkIdArr.length; j++) {
                            for (let i = 0; i < curLiDom.length; i++) {
                                if (curLiDom.eq(i).find(".checkbox").length == 0) {//单选
                                    if (curLiDom[i].dataset["id"] && curLiDom[i].dataset["id"].toUpperCase() == checkIdArr[j].toUpperCase()) {
                                        curLiDom[i].className = "active";
                                    } else {
                                        curLiDom[i].className = "";
                                    }
                                } else {//多选
                                    if (curLiDom[i].dataset["id"] && curLiDom[i].dataset["id"].toUpperCase() == checkIdArr[j].toUpperCase()) {
                                        curLiDom.eq(i).children("input").checked = true;
                                    } else {
                                        curLiDom.eq(i).children("input").checked = false;
                                    }
                                }
                            }
                        }
                    } else if ($(this).next().hasClass("linkage_menu")) {//联想
                        $(this).children("i").removeClass("iconxiajiantou").addClass("iconshangjiantou");
                        $(this).siblings().show();
                        return;
                    } else if ($(this).next().hasClass("dropdown_menu")) {//单选
                        // 可以选择两个选项的下拉框，选中一个后不关闭 tp：父标签-子标签
                        if (!$(this).parents(".dropdown_box").hasClass("dropdown_box_select2")) {
                            let curLiDom = $(this).next().children("li");
                            for (let j = 0; j < checkIdArr.length; j++) {
                                curLiDom.each(function (e) {
                                    if ($(this).attr("data-id") && $(this).attr("data-id").toUpperCase() === checkIdArr[j].toUpperCase()) {
                                        $(this).addClass("active").siblings().removeClass("active");
                                    }
                                });
                            }
                        } else {
                            // 可选择两个选项  
                            let curLiDom1 = $(this).next().children("li.select_2_list1");
                            let curLiDom2 = $(this).next().children("li.select_2_list2");
                            curLiDom1.removeClass("active");
                            curLiDom1.each(function (e) {
                                if ($(this).attr("data-id") && $(this).attr("data-id").toUpperCase() === checkIdArr[0].split("--")[0].toUpperCase()) {
                                    $(this).addClass("active");
                                }
                            });
                            curLiDom2.removeClass("active");
                            curLiDom2.each(function (e) {
                                if ($(this).attr("data-id") && $(this).attr("data-id").toUpperCase() === checkIdArr[0].split("--")[1].toUpperCase()) {
                                    $(this).addClass("active");
                                }
                            });
                        }
                    } else if ($(this).next().hasClass("dropdown_menu_check")) {//多选
                        var curCheckDom = $(this).next().children("li");
                        // 初始化清空选择
                        curCheckDom.each(function (i) {
                            if ($(this).find("input").length > 0) {
                                $(this).find("input").attr("checked", false);
                            }
                        })
                        for (let j = 0; j < checkIdArr.length; j++) {
                            curCheckDom.each(function (i) {
                                if ($(this).attr("data-id").toUpperCase() == checkIdArr[j].toUpperCase()) {
                                    if ($(this).find("input").length > 0) {
                                        $(this).find("input")[0].checked = true;
                                        // $(this).find("label").click();
                                    }
                                }
                            })
                        }
                    }
                    $(this).children("i").removeClass("iconxiajiantou").addClass("iconshangjiantou");
                    // 校验溢出隐藏遮挡，显示位置控制
                    if ($(this).parents(".overflow_table").length > 0) {
                        let curboxOffset = $(this).parents(".dropdown_box").offset();
                        let curboxWid = $(this).parents(".dropdown_box")[0].clientWidth;
                        let curboxHei = $(this).parents(".dropdown_box")[0].clientHeight;
                        $(this).parents(".dropdown_box").find(".dropdown_menu").css({ position: 'fixed', top: curboxOffset.top + curboxHei + 2 - window.scrollY, left: curboxOffset.left, width: curboxWid });
                    }
                    $(this).siblings().show();
                }
            });
            //移出下拉框时 关闭下拉选项
            $(`${parentDom}`).on("mouseleave", ".dropdown_box", function () {
                let menuToggle = $(this).find(".dropdown_input i").hasClass("iconshangjiantou");
                if (menuToggle && $(this).find(".dropdown_menu_hascheck").length > 0) {
                    // 单选、也有多选
                    if ($(this).find(".dropdown_menu_hascheck li.active").length > 0) {//有单选的li 选择单选；
                        let value = $(this).find(".dropdown_menu_hascheck li.active").data("value");
                        let selectid = $(this).find(".dropdown_menu_hascheck li.active").data("id");
                        $(this).find(".dropdown_value").attr("data-selectid", selectid).html(value).attr("title", value);
                    } else {
                        var selectObj = getSelectMen($(this).find(".dropdown_menu_hascheck"));
                        $(this).find(".dropdown_value").attr("data-selectid", selectObj.selectMenId).html(selectObj.selectMen).attr("title", selectObj.selectMen);
                    }
                    $(this).find(".dropdown_input i").removeClass("iconshangjiantou").addClass("iconxiajiantou");
                    $(this).find(".dropdown_menu_hascheck").hide();
                } else if (menuToggle && $(this).find(".dropdown_menu").length > 0) {
                    // 单选 同时选择两个选项集
                    if ($(this).find(".dropdown_input input").length == 0) {
                        $(this).find(".dropdown_input i").removeClass("iconshangjiantou").addClass("iconxiajiantou");
                        $(this).find(".dropdown_menu").hide();
                    }
                } else if (menuToggle && $(this).find(".dropdown_menu_check").length > 0) {
                    // 多选
                    var selectObj = getSelectMen($(this).find(".dropdown_menu_check"));
                    $(this).find(".dropdown_value").attr("data-selectid", selectObj.selectMenId);
                    if ($(this).find(".dropdown_value")[0].nodeName == 'INPUT') {
                        $(this).find(".dropdown_value").val(selectObj.selectMen).attr("title", selectObj.selectMen);
                    } else {
                        $(this).find(".dropdown_value").html(selectObj.selectMen).attr("title", selectObj.selectMen);
                    }
                    $(this).find(".dropdown_input i").removeClass("iconshangjiantou").addClass("iconxiajiantou");
                    $(this).find(".dropdown_menu_check").hide();
                }
            });
            // 下拉框选择
            $(`${parentDom}`).on("click", ".dropdown_box li", function (e) {
                Util.stopEvent(e);
                let value = $(this).data("value");
                let selectid = $(this).data("id");
                if ($(this).parents(".ContactTypeList").length > 0) {//工作明细 接触方式选择营销活动，营销活动才可下拉
                    if (selectid == "20-H") {
                        $(".Htf_MarketActivityType").parents(".dropdown_box").removeClass("readonly");
                    } else {
                        $(".Htf_MarketActivityType").parents(".dropdown_box").addClass("readonly");
                        $(".Htf_MarketActivityType").html("不限").attr("data-selectid", "00");
                    }
                }
                if ($(this).parents(".dropdown_menu_hascheck").length > 0 && e.target.nodeName != 'INPUT') {//既有单选又有多选
                    if ($(this).find(".checkbox").length == 0) {//单选
                        for (let i = 0; i < $(this).parent().find("li input").length; i++) {
                            $(this).parent().find("li input").eq(i).attr("checked", false);
                        }
                        $(this).addClass("active").siblings().removeClass("active");
                        $(this).parents(".dropdown_box").find(".dropdown_value").html(value).attr("data-selectid", selectid);
                    } else {//多选
                        $(this).siblings().removeClass("active");
                    }
                } if ($(this).parents(".linkage_menu").length > 0) {//联想下拉框
                    return;
                } else if ($(this).parents(".dropdown_menu_check").length > 0 && e.target.nodeName != 'INPUT') {
                    // let nowChecked = $(this).find("input")[0].checked;采用优化显示的方式，不需要控制选择
                    // $(this).find("input")[0].checked = !nowChecked;
                    if (selectid === "00") {//选择不限 清除其他选择
                        for (let i = 1; i < $(this).parent().find("li input").length; i++) {
                            $(this).parent().find("li input").eq(i).attr("checked", false);
                        }
                    } else {
                        if ($(this).parent().find("li").eq(0).attr("data-id") == "00") {
                            $(this).parent().find("li input").eq(0).attr("checked", false);//选择其它选项清除不限选择状态
                        }
                    }
                } else if (e.target.nodeName != 'INPUT') {
                    // 可以选择两个选项的下拉框，选中一个后不关闭 tp：父标签-子标签
                    if (!$(this).parents(".dropdown_box").hasClass("dropdown_box_select2")) {
                        // 普通下拉选择
                        $(this).addClass("active").siblings().removeClass("active");
                        $(this).parents(".dropdown_box").find(".dropdown_value").attr("data-selectid", selectid);
                        if ($(this).parents(".dropdown_box").find(".dropdown_value")[0].nodeName == 'INPUT') {
                            $(this).parents(".dropdown_box").find(".dropdown_value").val(value);
                        } else {
                            $(this).parents(".dropdown_box").find(".dropdown_value").html(value);
                        }
                        $(this).parent().hide().prev().children("i").removeClass("iconshangjiantou").addClass("iconxiajiantou");
                    } else {
                        // 可选择两个选项  
                        let selectidOther, valueOther;//选择的另一个选项
                        if ($(this).hasClass("select_2_list1")) {
                            // 选中第一个选项 清空第一个选项集合的active
                            $(this).parents(".dropdown_menu").find(".select_2_list1").removeClass("active");
                            // 用两个短线相连两个选项 "--"
                            selectidOther = selectid + "--" + $(this).parents(".dropdown_menu").find(".select_2_list2.active").attr("data-id");
                            valueOther = value + "-" + $(this).parents(".dropdown_menu").find(".select_2_list2.active").attr("data-value");
                        } else if ($(this).hasClass("select_2_list2")) {
                            // 选中第二个选项 清空第二个选项集合的active
                            $(this).parents(".dropdown_menu").find(".select_2_list2").removeClass("active");
                            // 用两个短线相连两个选项 "--"
                            selectidOther = $(this).parents(".dropdown_menu").find(".select_2_list1.active").attr("data-id") + "--" + selectid;
                            valueOther = $(this).parents(".dropdown_menu").find(".select_2_list1.active").attr("data-value") + "-" + value;
                        }
                        $(this).addClass("active");
                        // 赋值
                        $(this).parents(".dropdown_box").find(".dropdown_value").attr("data-selectid", selectidOther);
                        $(this).parents(".dropdown_box").find(".dropdown_value").html(valueOther);
                        // 这种情况不用关闭下拉框
                    }
                }
            });
            //多选
            function getSelectMen(dom) {
                var liArr = dom.children("li");
                var selectMen = [];
                var selectMenId = [];
                for (let i in liArr) {
                    if (i > 0 && liArr.eq(i).find("input").length > 0 && liArr.eq(i).find("input")[0].checked) {//选中
                        selectMen.push(liArr[i].dataset["value"]);
                        selectMenId.push(liArr[i].dataset["id"]);
                    }
                }
                if (selectMen.length === 0) {
                    selectMen.push($(liArr[0]).attr("data-value") || "不限");
                    selectMenId.push($(liArr[0]).attr("data-id") || "00");
                }
                return {
                    "selectMen": selectMen.join(";"),
                    "selectMenId": selectMenId.join(",")
                }
            }
            // 页面滚动时关闭下拉框
            // $(window).on("scroll",function(){
            //     if( $(".dropdown_input .iconshangjiantou").length > 0 ){
            //         $(".dropdown_input .iconshangjiantou").parents(".dropdown_box").mouseleave();
            //     }
            // });
        },
        // 获取url参数
        getURLParams: function (pKey, pUrl) {
            var url = !!pUrl ? pUrl : window.location.href;
            var index = url.indexOf('?') + 1;
            var search = url.substr(index);
            var reg = new RegExp("(^|&)" + pKey + "=([^&]*)(&|$)*", "i");
            var r = search.match(reg);
            return r && r.length > 2 ? r[2] : '';
        },
        // 初始化时间datetimepicker 可自定义参数
        InitTimeFn: function (DomId, options) {
            var Dom = typeof (DomId) === "string" ? $(`#${DomId}`) : DomId;
            // 设置时间
            var dateOptions = {
                language: 'zh-CN',
                format: "yyyy-mm-dd",
                autoClose: 1,
                startView: 2,//4 year;3 month;2 day;1 hour
                minView: "month",
                autoclose: true,
                clearBtn: true
                // endDate:new Date()
            }
            $.extend(dateOptions, options);
            Dom.datetimepicker(dateOptions);
        },
        /**
         * StartEndTimeRangeFn 时间段初始化 有时间段限制
         * @param {*} StartDom 开始Input
         * @param {*} EndDom 结束Input
         * @param {*} options 
         */
        StartEndTimeRangeFn: function (StartDomId, EndDomId, optionsStart, optionsEnd) {
            //SetEndDate 设置结束时间
            var dateOptionsStart = {
                language: 'zh-CN',
                format: "yyyy-mm-dd",
                autoClose: 1,
                startView: 2,
                minView: "month",
                autoclose: true,
                clearBtn: true
                // endDate:new Date()
            }
            var dateOptionsEnd = {
                language: 'zh-CN',
                format: "yyyy-mm-dd",
                autoClose: 1,
                startView: 2,
                minView: "month",
                autoclose: true,
                clearBtn: true
                // endDate:new Date()
            }
            $.extend(dateOptionsStart, optionsStart);
            $.extend(dateOptionsEnd, optionsEnd);
            $(`#${StartDomId}`).datetimepicker(dateOptionsStart).on('changeDate', function (ev) {
                // 有只有月日的情况
                let timeStart = $(`#${StartDomId}`).val() && $(`#${StartDomId}`).val().length > 5 ? $(`#${StartDomId}`).val() : new Date().getFullYear() + "-" + $(`#${StartDomId}`).val(),
                    timeEnd = $(`#${EndDomId}`).val() && $(`#${EndDomId}`).val().length > 5 ? $(`#${EndDomId}`).val() : new Date().getFullYear() + "-" + $(`#${EndDomId}`).val();
                if (timeEnd && timeStart && (Number(timeStart.replace(/-|\s|\:/g, "")) > Number(timeEnd.replace(/-|\s|\:/g, "")))) {
                    $(`#${EndDomId}`).val("").datetimepicker('setStartDate', timeStart);
                } else if (timeStart) {
                    $(`#${EndDomId}`).datetimepicker('setStartDate', timeStart);
                } else {
                    $(`#${EndDomId}`).datetimepicker('setStartDate', "0001-01-01");
                }
            });
            $(`#${EndDomId}`).datetimepicker(dateOptionsEnd);
        },
        /**
         * StartEndTimeFn 时间段初始化
         * @param {*} StartDomId 开始Input 传参$("#id") 或 id
         * @param {*} EndDomId 结束Input
         * @param {*} SetEndDate 设置结束时间的最晚时间 默认今日
         * @param {*} SetStartEndDate 设置开始时间的最晚时间 默认今日
         */
        StartEndTimeFn: function (StartDomId, EndDomId, SetEndDate, SetStartEndDate) {
            var StartDom = typeof (StartDomId) === "string" ? $(`#${StartDomId}`) : StartDomId;
            var EndDom = typeof (EndDomId) === "string" ? $(`#${EndDomId}`) : EndDomId;
            //SetEndDate 设置结束时间
            var dateOptionsStart = {
                language: 'zh-CN',
                format: "yyyy-mm-dd",
                autoClose: 1,
                startView: 2,
                minView: "month",
                autoclose: true,
                clearBtn: true,
                endDate: (SetStartEndDate || (SetStartEndDate === "")) ? SetStartEndDate : new Date()
            }
            var dateOptionsEnd = {
                language: 'zh-CN',
                format: "yyyy-mm-dd",
                autoClose: 1,
                startView: 2,
                minView: "month",
                autoclose: true,
                clearBtn: true,
                endDate: (SetEndDate || (SetEndDate === "")) ? SetEndDate : new Date()
            }
            StartDom.datetimepicker(dateOptionsStart).on('changeDate', function (ev) {
                let timeStart = StartDom.val(),
                    timeEnd = EndDom.val();
                if (timeEnd && timeStart && (Number(timeStart.replace(/-/g, "")) > Number(timeEnd.replace(/-/g, "")))) {
                    EndDom.val("").datetimepicker('setStartDate', timeStart);
                } else if (timeStart) {
                    EndDom.datetimepicker('setStartDate', timeStart);
                } else {
                    EndDom.datetimepicker('setStartDate', "0001-01-01");
                }
            });
            EndDom.datetimepicker(dateOptionsEnd);
        },
        //设置时间段 new_dateRangePicker
        SetTimeQuantumFn: function (DomId, beginTimeStore, endTimeStore, Options) {
            let Dom;
            if (typeof (DomId) === "string" && DomId.indexOf("#") != -1) {
                Dom = $(DomId);
            } else if (typeof (DomId) === "string") {
                Dom = $(`#${DomId}`);
            } else {
                Dom = DomId;
            }
            if (!!beginTimeStore && !!endTimeStore) {
                Dom.val(beginTimeStore + " 至 " + endTimeStore);
            }
            var dateOptions = {
                timePicker: false,
                timePicker24Hour: false,
                timePickerSeconds: false,//可选中秒
                linkedCalendars: false,
                autoUpdateInput: false,
                locale: {
                    format: 'YYYY-MM-DD',
                    separator: ' 至 ',
                    applyLabel: "应用",
                    cancelLabel: "取消",
                    resetLabel: "重置",
                },
                startDate: beginTimeStore,
                endDate: endTimeStore,
            };
            $.extend(dateOptions, Options);
            Dom.daterangepicker(dateOptions, function (start, end, label) {
                beginTimeStore = this.startDate.format(this.locale.format);
                endTimeStore = this.endDate.format(this.locale.format);
                if (!this.startDate) {
                    this.element.val('');
                } else {
                    this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
                }
            });
        },
        /**
         * 滚动时表头固定（虚拟头部）
         * @param {表格外层div或者tableId} TableOutDOMOrTable 没有自定义冻结列需求时或不是多个表格时，可以不用传这个参数
         */
        ScrollShowHead: function (TableOutDOMOrTable) {
            var TableOutDOM = $(".table_outer div.content_table").length >= 1 ? $(".table_outer div.content_table") : $(".table_outer>div:nth-child(1)"),
                TableId = TableOutDOM.find("table.table").attr("id");
            // 传参是dom对象
            if (!!TableOutDOMOrTable && typeof (TableOutDOMOrTable) === 'object' && TableOutDOMOrTable.length > 0 && TableOutDOMOrTable[0].tagName === 'DIV') {
                TableOutDOM = TableOutDOMOrTable;
                TableId = TableOutDOMOrTable.find("table.table").attr("id");
            } else if (!!TableOutDOMOrTable && typeof (TableOutDOMOrTable) === 'object' && TableOutDOMOrTable.length > 0 && TableOutDOMOrTable[0].tagName === 'TABLE') {
                TableOutDOM = TableOutDOMOrTable.parents(".content_table");
                TableId = TableOutDOMOrTable.attr("id");
            } else if (!!TableOutDOMOrTable && typeof (TableOutDOMOrTable) === 'string' && $(`#${TableOutDOMOrTable}`)[0].tagName === 'TABLE') {
                TableOutDOM = $(`#${TableOutDOMOrTable}`).parents(".content_table");
                TableId = $(`#${TableOutDOMOrTable}`).attr("id");
            } else if (!!TableOutDOMOrTable && typeof (TableOutDOMOrTable) === 'string' && TableOutDOMOrTable.includes("#")) {
                TableOutDOM = $(`${TableOutDOMOrTable}`).parents(".content_table");
                TableId = $(`${TableOutDOMOrTable}`).attr("id");
            }
            var ScrollClass = "show-head-box" + TableId,
                ScrollBGClass = "show-head-box-bg" + TableId;
            $(window).on("resize", function () {
                if ($(`.${ScrollClass}`).length == 0) {
                    return;
                }
                $(`.${ScrollClass}`).css("width", TableOutDOM[0].clientWidth);
                $(".show-head-operate table>thead").html(TableOutDOM.find("table thead").html());
            });
            $(window).on("scroll", function () {
                let winScrollX = $(this)[0].scrollX;
                if ($(`.${ScrollClass}`).length > 0) {
                    let tableScrollLeft = TableOutDOM.find(" .fixed-table-body")[0].scrollLeft;
                    $(`.${ScrollClass} .show-head`).css("margin-left", `-${tableScrollLeft + winScrollX}px`);
                }
                setScrollHead(TableOutDOM, winScrollX);
            });
            //滚动到页面下方，设置提示表头
            function setScrollHead(TableOutDOM, winScrollX) {
                let tableHeight = TableOutDOM[0].clientHeight;
                let tableWidth = TableOutDOM.find("table.table")[0].clientWidth;
                let tableThHeight = TableOutDOM.find("table.table thead")[0].clientHeight;
                let tableTop = 0;
                if (TableOutDOM[0].offsetParent && TableOutDOM[0].offsetParent.nodeName !== "BODY") {
                    tableTop = TableOutDOM[0].offsetParent.offsetTop;
                } else if (TableOutDOM[0].parentNode) {
                    tableTop = TableOutDOM[0].parentNode.offsetTop;
                }
                let tableSLeft1 = TableOutDOM.find(" .fixed-table-body")[0].scrollLeft;
                if ($(`.${ScrollClass}`).length == 0 && ($(this)[0].scrollY > tableTop) && ($(this)[0].scrollY < (tableTop + tableHeight))) {
                    // 插入冻结头部代码
                    TableOutDOM.prepend(`<div class='show-head-box ${ScrollClass}' style='width:${tableWidth}px'><table class='show-head' style='margin-left:-${tableSLeft1}px;width:${TableOutDOM.find(" table thead")[0].clientWidth}px;table-layout:fixed;'><thead>${TableOutDOM.find(" table thead").html()}</thead></table></div>`);
                    TableOutDOM.prepend(`<div class='show-head-box-bg ${ScrollBGClass}' style='position:fixed;top:0;left:0;z-index:999;background:#fff;width:100%;height:${$(`.${ScrollClass}`)[0].clientHeight}px;'></div>`);
                    // 有冻结列的情况
                    if ($(".fixed-table-body-columns").length > 0) {
                        $(`.${ScrollClass}`).prepend(`<div class="fixed-columns" style="width:${$(".fixed-table-body-columns").width() + 'px'}"><table class="fixed-columns-table" style="width:100%;table-layout:fixed;"><thead>${$(".fixed-table-body-columns thead").html()}</thead></table></div>`);
                    }
                    // 调整冻结头部th宽度
                    $(`.${ScrollClass} .show-head thead th`).each(function (i) {
                        $(this).css({ width: TableOutDOM.find("table.table thead th").eq(i).css("width") });
                        $(this).click(function () {
                            TableOutDOM.find("table.table thead th").eq(i).find(".th-inner").click();
                        });
                        $(this).find("i").click(function (e) {
                            Util.stopEvent(e);
                            TableOutDOM.find("table.table thead th").eq(i).find("i").click();
                            $("html,body").animate({
                                scrollTop: 0
                            }, 300);
                        });
                        // $(this).find(".th-inner").css({padding:TableOutDOM.find("table.table thead th").eq(i).find(".th-inner").css("padding")});
                    });
                    $(`.${ScrollClass} input`).remove();
                } else if ($(this)[0].scrollY <= tableTop || $(this)[0].scrollY >= (tableTop + tableHeight)) {
                    $(`.${ScrollClass}`).remove();
                    $(`.${ScrollBGClass}`).remove();
                }
                TableOutDOM.find(" .fixed-table-body").unbind("scroll").on("scroll", function () {
                    let tableScrollLeft = $(this)[0].scrollLeft;
                    if ($(`.${ScrollClass}`).length > 0) {
                        $(`.${ScrollClass} .show-head`).css("margin-left", `-${tableScrollLeft + winScrollX}px`);
                    }
                });
            }
        },
        /**
         * 替换链接参数刷新页面
         * @param {数组 url键} ReplaceParamName 
         * @param {数组 url键对应的值} NewParamVal 
         * @param {string 想要跳转的链接，默认当前页面} initHref 
         */
        ReloadByNewParam: function (ReplaceParamName, NewParamVal, initHref) {
            var LocalParams = !!initHref ? '' : $(window)[0].location.search.replace(/\{|\}/g, ""),
                hrefPre = !!initHref ? initHref : $(document)[0].location.href;
            ReplaceParamName.forEach(function (val, index, arr) {
                let valuePre = Util.getURLParams(val, LocalParams) ? Util.getURLParams(val, LocalParams) : "";
                if (hrefPre.indexOf(`&${val}=${valuePre}`) !== -1) {
                    hrefPre = hrefPre.replace(`&${val}=${valuePre}`, `&${val}=${NewParamVal[index]}`);
                } else if (hrefPre.indexOf(`?${val}=${valuePre}`) !== -1) {
                    hrefPre = hrefPre.replace(`?${val}=${valuePre}`, `?${val}=${NewParamVal[index]}`);
                } else {
                    hrefPre = hrefPre.replace(`?`, `?${val}=${NewParamVal[index]}&`);//添加新参数
                }
            });
            !!initHref ? window.open(hrefPre, "_blank") : $(document)[0].location.href = hrefPre;
        },
        // 公共请求方法
        iAjaxGet: function (code, SuccessFn, ErrorFn, ThenFn, async) {
            $("#loadModel").modal("show");
            $.ajax({
                type: 'GET',
                contentType: "application/json",
                url: code,
                async: async === false ? false : true,//默认true异步
                dataType: "json",
                success: function (res) {
                    $("#loadModel").modal("hide");
                    SuccessFn ? SuccessFn(res) : null;
                },
                error: function (e) {
                    $("#loadModel").modal("hide");
                    console.log(code + ":", e.responseJSON);
                    ErrorFn ? ErrorFn(e) : null;
                }
            }).then(function (res) {
                $("#loadModel").modal("hide");
                ThenFn ? ThenFn(res) : null;
            });
        },
        // 公共请求方法
        iAjax: function (code, queryJson, SuccessFn, ErrorFn, ThenFn, async) {
            $("#loadModel").modal("show");
            $.ajax({
                type: 'POST',
                contentType: "application/json",
                url: "/api/data/v8.2/new_MainAction",
                async: async === false ? false : true,//默认true异步
                data: JSON.stringify({
                    InMsg: JSON.stringify({
                        new_interface_code: code,
                        new_params: JSON.stringify(queryJson || {})
                    })
                }),
                dataType: "json",
                success: function (res) {
                    $("#loadModel").modal("hide");
                    var outPutMsg = JSON.parse(res.OutMsg);
                    console.log(code + ":", "queryJson--", queryJson, "OutMsg--", outPutMsg);
                    // 后台返回的数据参数不同
                    if (outPutMsg.code == 1 || outPutMsg.error == '200') {
                        SuccessFn ? SuccessFn(res) : null;
                    } else {
                        // 兼容返回参数
                        if (!!outPutMsg.error && !!outPutMsg.errormsg) {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.errormsg}`);
                        } else if (!!outPutMsg.data && !!outPutMsg.data.data && !!outPutMsg.data.data.error && outPutMsg.data.data.errormsg !== undefined) {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.data.data.errormsg}`);
                        } else {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.error}`);
                        }
                        ErrorFn ? ErrorFn(res) : null;
                    }
                },
                error: function (e) {
                    $("#loadModel").modal("hide");
                    console.log(code + ":", "queryJson--", queryJson, 'error--', e.responseJSON.error.innererror);
                    // 存在不同的返回格式
                    if (JSON.parse(e.responseJSON.error.message).error) {
                        Util.BootstrapDialogAlert(`${code}:${JSON.parse(e.responseJSON.error.message).error}`);
                    } else if (JSON.parse(e.responseJSON.error.message).data && JSON.parse(e.responseJSON.error.message).data.errormsg) {
                        Util.BootstrapDialogAlert(`${code}:${JSON.parse(e.responseJSON.error.message).data.errormsg}`);
                    }
                    ErrorFn ? ErrorFn(e) : null;
                }
            }).then(function (res) {
                ThenFn ? ThenFn(res) : null;
            });
        },
        // 公共请求方法不初始化loading
        iAjaxNoLoading: function (code, queryJson, SuccessFn, ErrorFn, ThenFn, async) {
            $.ajax({
                type: 'POST',
                contentType: "application/json",
                url: "/api/data/v8.2/new_MainAction",
                async: async === false ? false : true,//默认true异步
                data: JSON.stringify({
                    InMsg: JSON.stringify({
                        new_interface_code: code,
                        new_params: JSON.stringify(queryJson || {})
                    })
                }),
                dataType: "json",
                success: function (res) {
                    if( !ThenFn ){
                        $("#loadModel").modal("hide");
                    }
                    var outPutMsg = JSON.parse(res.OutMsg);
                    console.log(code + ":", "queryJson--", queryJson, "OutMsg--", outPutMsg);
                    // 后台返回的数据参数不同
                    if (outPutMsg.code == 1 || outPutMsg.error == '200') {
                        SuccessFn ? SuccessFn(res) : null;
                    } else {
                        // 兼容返回参数
                        if (!!outPutMsg.error && !!outPutMsg.errormsg) {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.errormsg}`);
                        } else if (!!outPutMsg.data && !!outPutMsg.data.data && !!outPutMsg.data.data.error && outPutMsg.data.data.errormsg !== undefined) {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.data.data.errormsg}`);
                        } else {
                            Util.BootstrapDialogAlert(`<span class="hide">${code}</span>${outPutMsg.error}`);
                        }
                        ErrorFn ? ErrorFn(res) : null;
                    }
                },
                error: function (e) {
                    $("#loadModel").modal("hide");
                    console.log(code + ":", "queryJson--", queryJson, 'error--', e.responseJSON.error.innererror);
                    // 存在不同的返回格式
                    if (JSON.parse(e.responseJSON.error.message).error) {
                        Util.BootstrapDialogAlert(`${code}:${JSON.parse(e.responseJSON.error.message).error}`);
                    } else if (JSON.parse(e.responseJSON.error.message).data && JSON.parse(e.responseJSON.error.message).data.errormsg) {
                        Util.BootstrapDialogAlert(`${code}:${JSON.parse(e.responseJSON.error.message).data.errormsg}`);
                    }
                    ErrorFn ? ErrorFn(e) : null;
                }
            }).then(function (res) {
                ThenFn ? ThenFn(res) : null;
            });
        },
        // 公共请求方法 360
        iAjax360: function (queryJson, SuccessFn, ErrorFn, ThenFn) {
            $.ajax({
                type: 'POST',
                contentType: "application/json",
                url: "/api/data/v8.2/htf_action_360",
                data: JSON.stringify({ input: JSON.stringify(queryJson || {}) }),
                dataType: "json",
                success: function (res) {
                    $("#loadModel").modal("hide");
                    var outPutMsg = JSON.parse(res.output);
                    console.log(queryJson.name + ":", outPutMsg);
                    if (!outPutMsg.error || Number(outPutMsg.error) > 0) {
                        SuccessFn ? SuccessFn(res) : null;
                    } else {
                        Util.BootstrapDialogAlert(`${queryJson.name}:${outPutMsg.error}`);
                    }
                },
                error: function (e) {
                    $("#loadModel").modal("hide");
                    console.log(queryJson.name + ":", e.responseText);
                    Util.BootstrapDialogAlert(`${queryJson.name}:${e.responseText}`);
                    ErrorFn ? ErrorFn(e) : null;
                }
            }).then(function (res) {
                ThenFn ? ThenFn(res) : null;
            });
        },
        /**
         * 弹窗提示
         * @param {提示内容} alertContent 
         * @param {配置项或回调方法} Opts 
         */
        BootstrapDialogAlert: function (alertContent, Opts) {
            BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = '提示';
            BootstrapDialog.DEFAULT_TEXTS['OK'] = '确定';
            if( !!Opts && typeof(Opts) == 'object'){
                BootstrapDialog.defaultOptions = $.extend(BootstrapDialog.defaultOptions, Opts);
            }
            if( !!Opts && typeof(Opts) == 'function'){
                BootstrapDialog.alert(alertContent,Opts);
            }else{
                BootstrapDialog.alert(alertContent);
            }
        },
        BootstrapDialogSubmit: function ($message, SubmitFunction, CancelFunction, Opts) {
            // BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = '提示';
            // BootstrapDialog.DEFAULT_TEXTS['OK'] = '确定';
            BootstrapDialog.defaultOptions = $.extend(BootstrapDialog.defaultOptions, Opts);
            BootstrapDialog.show({
                title: BootstrapDialog.defaultOptions.title || '提示',
                message: function () {
                    return $message;
                },
                closable: false,
                buttons: [{
                    label: BootstrapDialog.defaultOptions.cancelText || '否',
                    cssClass: 'btn_cancel',
                    action: function (dialogRef1) {
                        dialogRef1.close();
                        CancelFunction ? CancelFunction() : null;
                    }
                }, {
                    label: BootstrapDialog.defaultOptions.submitText || '是',
                    action: function (dialogRef1) {
                        dialogRef1.close();
                        SubmitFunction ? SubmitFunction() : null;
                    }
                }]
            });
        },
        BootstrapAlert: function (alertContent, alertType, timeRange) {
            alertType = alertType || 'danger';//success info warning danger
            timeRange = timeRange || 2000;
            if ($("#BootstrapAlert").length === 0) {
                $("body").append(`<div class="alert alert-${alertType}" id="BootstrapAlert" style="position: fixed;
                top: 20px;
                left: 50%;
                min-width: 300px;
                transform: translateX(-50%);
                z-index: 9999;">
                    <strong>抱歉！</strong><span class="alertText">${alertContent}</span>
                </div>`);
            } else {
                $("#BootstrapAlert").addClass(`alert-${alertType}`);
                $("#BootstrapAlert .alertText").html(alertContent);
                $("#BootstrapAlert").show();
            }
            let alertTimeOut = setTimeout(function () {
                $("#BootstrapAlert").hide();
                $("#BootstrapAlert").removeClass(`alert-${alertType}`);
                clearTimeout(alertTimeOut);
            }, timeRange);
        },
        //TooltipFormatter echarts 与前一个数据相比的增长百分比
        TooltipFormatter: function (para, AllData, title, hideName) {
            let p = para[0] || para;//一条折线和tooltip为cross传参不同
            if (!p.name && !p.axisValueLabel) {//如果坐标为空则不显示
                return "";
            };
            if (hideName) {//多个legend时 只显示一次x轴数据
                p.name = "";
            }
            let showName = (p.name ? p.name + `<br/>` : "");
            title = `<span style='display:inline-block;width:8px;height:8px;border-radius:50%;background:` + p.color + `;'></span>&nbsp;` + title;
            if (p.dataIndex === 0) {
                return showName + title + `:&nbsp;` + Util.FormatThousand(p.data);
            };
            let NowData = Number(p.data),
                BeforeData = Number(AllData[p.dataIndex - 1]);
            let dotHtml = title + `:&nbsp;` + Util.FormatThousand(NowData) + `<br/>增长百分比:&nbsp;<span style='display:inline-block;width:8px;height:8px;border-radius:50%;background:DotColor;'></span>&nbsp;`;
            if (BeforeData === 0) {
                return showName + title + `:&nbsp;` + Util.FormatThousand(p.data);
            }
            let val = (((NowData - BeforeData) / BeforeData) * 100).toFixed(2) + '%';
            if (NowData >= BeforeData) {
                dotHtml = dotHtml.replace("DotColor", "#D13C3C");
                val = "+" + val;
            } else {
                dotHtml = dotHtml.replace("DotColor", "#2AAF7B");
            }
            return showName + dotHtml + val;
        },
        //字段显示进度条
        FormatProgressFn(value) {
            let progressValue = value.toString();
            if (progressValue.indexOf("%") == -1) {
                let html = `<div class="progress" style="position: relative;"><span style="position: absolute;left: 10%;text-shadow: 0 0 4px rgba(221,175,89,1);color: #fff;">` + progressValue + `%</span>`;
                html += `<div class="progress-bar" role="progressbar" aria-valuenow="` + progressValue + `" aria-valuemin="0" aria-valuemax="100" style="width: `;
                html += progressValue + `%;"></div></div>`;
                return html;
            }
            if (progressValue.indexOf("%") != -1) {
                let html = `<div class="progress" style="position: relative;"><span style="position: absolute;left: 10%;text-shadow: 0 0 4px rgba(221,175,89,1);color: #fff;">` + progressValue + `</span>`;
                html += `<div class="progress-bar" role="progressbar" aria-valuenow="` + progressValue.replace("%", "") + `" aria-valuemin="0" aria-valuemax="100" style="width: `;
                html += progressValue + `;"></div></div>`;
                return html;
            }
        },
        //字段显示进度条//小数
        FormatProgressDecimalFn(value) {
            let progressValue = (value * 100).toFixed(2).toString();
            let html = "";
            if (value * 100 < 100) {
                html += `<div class="progress" style="position: relative;"><span style="position: absolute;left: 10%;text-shadow: 0 0 4px rgba(221,175,89,1);color: #fff;">` + progressValue + `%</span>`;
                html += `<div class="progress-bar" role="progressbar" aria-valuenow="` + progressValue + `" aria-valuemin="0" aria-valuemax="100" style="width: `;
                html += progressValue + `%;"></div></div>`;
            } else {
                html += `<div class="progress" style="position: relative;"><span style="position: absolute;left: 10%;text-shadow: 0 0 4px rgba(221,175,89,1);color: #fff;">` + progressValue + `%</span>`;
                html += `<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: `;
                html += `100%;"></div></div>`;
            }
            return html;
        },
        // 查重
        NoRepeatArray: function (arr) {
            return Array.from(new Set(arr.filter(function (item, index, self) {
                return self.indexOf(item) !== index;
            })));
        },
        // 去重
        UniqueArray: function (arr) {
            return Array.from(new Set(arr));
        },
        // 交集
        UnionArray: function (arrA, arrB) {
            let arr1 = JSON.parse(JSON.stringify(arrA));
            let arr2 = JSON.parse(JSON.stringify(arrB));
            return arr1.filter(item => {
                if (arr2.indexOf(item) > -1) {
                    arr2.splice(arr2.indexOf(item), 1);
                    return item
                }
            })
        },
        /**
         * 根据自定义下拉框选中的id 显示下拉框的选中值
         * @param {下拉框类名} Dom example："selectid"
         * @param {选中的id} id 
         */
        SetDropDownValue : function(Dom,id){
            if( id != 0 && !id ){
                return
            }
            $(`.${Dom}`).attr("data-selectid",id);
            if( $(`.${Dom}`).parents(".dropdown_box").find(".dropdown_menu").length > 0 ){
                let DomList = $(`.${Dom}`).parents(".dropdown_box").find(".dropdown_menu");
                DomList.find("li").each( (i,item)=>{
                    if( $(item).attr("data-id").toUpperCase() == id.toUpperCase() ){
                        $(`.${Dom}`).html( $(item).attr("data-value") ).attr("title", $(item).attr("data-value") );
                    }
                });
            }
        },
        /**
         * 根据公共接口获取下拉列表数据
         * @param {字段名称} AttributeName example："content"
         * @param {下拉列表类名} Dom example：".xxxList"
         * @param {实体名称} EntityName 
         * @param {期望的数组} FilterArr 
         * @param {格式化显示方法} formatFn 例如下拉选项是1,2,3转化为罗马数I，II，III 
         * @param {其它方法 例如赋值} 例如下拉选项是1,2,3转化为罗马数I，II，III 
         */
        GetDropDownData: function (AttributeName, Dom, EntityName, FilterArr, formatFn, async) {
            $.ajax({
                type: 'POST',
                contentType: "application/json",
                url: "/api/data/v8.2/new_MainAction",
                async: async === false ? false : true,//默认true异步
                data: JSON.stringify({
                    InMsg: JSON.stringify({
                        new_interface_code: 'I_Inter_GetInterPicklistList',
                        new_params: JSON.stringify({
                            filter: {
                                entity: EntityName,
                                attributename: AttributeName
                            }
                        })
                    })
                }),
                dataType: "json",
                success: function (data) {
                    let outPutList = JSON.parse(data.OutMsg);
                    if (!outPutList || !outPutList.data || !outPutList.data.Rows) {
                        return;
                    }
                    Util.PushMenuData(outPutList.data.Rows, Dom, FilterArr, formatFn);
                }
            });
        },
        /**
         * 渲染下拉选项
         * @param {渲染的数据} arrMsg 
         * @param {渲染的列表} dom tp:".list" 
         * @param {过滤的数据} FilterArr 
         * @param {数据处理} formatFn  如大写转小写等
         * @param {渲染的id键名} idKey 默认attributevalue
         * @param {渲染的name键名} nameKey 默认value
         * @param {渲染后事件} clickFn
         */
        PushMenuData: function (arrMsg, dom, FilterArr, formatFn, idKey, nameKey, clickFn) {
            idKey = idKey || "attributevalue";
            nameKey = nameKey || "value";
            $(dom).attr("data-all", JSON.stringify(arrMsg)).parents(".dropdown_box").removeClass("readonly").find("input").attr("disabled", false);
            // 下拉选择赋值
            let curValueDom , curSelectedId;
            if( $(dom).parents(".dropdown_box").find(".dropdown_value").length > 0 ){
                curValueDom = $(dom).parents(".dropdown_box").find(".dropdown_value");
                curSelectedId = curValueDom.attr("data-selectid");
            }
            var menuHtml = $(dom).html();
            arrMsg.map(function (item) {
                if (FilterArr && FilterArr.length > 0) {
                    if (FilterArr.indexOf(item.value) > -1) {
                        menuHtml += `<li title="${item[nameKey]}" data-value="${item[nameKey]}" data-id="${item[idKey]}">${item[nameKey]}</li>`;
                    }
                } else {
                    // 数据处理
                    formatFn ?
                        item[nameKey] = formatFn(item[nameKey])
                        :
                        null;
                    menuHtml += `<li title="${item[nameKey]}" data-value="${item[nameKey]}" data-id="${item[idKey]}">${item[nameKey]}</li>`;
                }
                // 选中选项并赋值给下拉框
                if( curSelectedId == item[idKey] && !!curValueDom){
                    curValueDom.html(item[nameKey]).attr("title",item[nameKey]);
                }
            })
            $(dom).html(menuHtml);
            // 渲染后事件
            clickFn ? clickFn() : null;
        },
        /**
         * 清空搜索项
         * @param {*} dom 清空按钮 $(this)
         * @param {*} crossrange 清空按钮在搜索表单同行显示
         */
        ClearFormFn: function (dom, crossrange) {
            var tableTdArr;
            if (crossrange) {//清空按钮在搜索表单同行显示
                tableTdArr = dom.parents(".search_form table").find("td");
            } else {
                tableTdArr = dom.parents(".content").find(".search_form table").find("td");
            }
            for (let i = 0; i < tableTdArr.length; i++) {
                let tdObj = tableTdArr.eq(i);
                tdObj.find(".checkbox").attr("checked", false);
                tdObj.find("input").val("").attr("data-selectid", "");
                tdObj.find(".dropdown_box input.dropdown_value").val("").attr("data-selectid", "00");
                // 初始化默认值可以自定义
                if (!!tdObj.find(".dropdown_box span.dropdown_value").attr("data-default")) {
                    let defaultId = tdObj.find(".dropdown_box span.dropdown_value").attr("data-default").split(",")[0];
                    let defaultName = tdObj.find(".dropdown_box span.dropdown_value").attr("data-default").split(",")[1];
                    tdObj.find(".dropdown_box span.dropdown_value").html(defaultName).attr("data-selectid", defaultId);
                } else {
                    //没有自定义默认值 初始化为不限
                    if (tdObj.find(".dropdown_box .dropdown_menu_check").length > 0) {
                        tdObj.find(".dropdown_box span.dropdown_value").html(tdObj.find(".dropdown_box .dropdown_menu_check li:first-child").attr("data-value")).attr("data-selectid", tdObj.find(".dropdown_box .dropdown_menu_check li:first-child").attr("data-id"));
                    } else {
                        tdObj.find(".dropdown_box span.dropdown_value").html(tdObj.find(".dropdown_box .dropdown_menu li:first-child").attr("data-value")).attr("data-selectid", tdObj.find(".dropdown_box .dropdown_menu li:first-child").attr("data-id"));
                    }
                }
                // 省市区联动
                if (tdObj.find(".dropdown_box input.dropdown_value").hasClass("cityInput") && tdObj.find(".dropdown_box input.dropdown_value").attr("id") !== "areaSearchS") {
                    tdObj.find(".dropdown_box").addClass("readonly");
                    tdObj.find(".dropdown_box input.dropdown_value").addClass("bgeee").attr("readonly", true);
                }
            }
        },
        FormatterCheck: function (value, row, index) {
            if (row.check == true) {
                //设置选中
                return { checked: true };
            }
        },
        // 组装json数组
        getSelectJson: function (Dom, Type) {
            let ArrName = Dom[0].nodeName === "INPUT" ? Dom.val().split(";") : Dom.html().split(";");
            let ArrId = Dom.attr("data-selectid").split(",");
            let JsonArr = [];
            // 去掉空值
            ArrName = ArrName.filter(item => {
                return item != ""
            });
            ArrName.forEach((element, index) => {
                let obj = {};
                obj.id = ArrId[index];
                obj.name = ArrName[index];
                obj.type = Type;
                JsonArr.push(obj);
            });
            return JsonArr;
        },
        // 获取json数组的id
        getJsonIds: function (JsonA) {
            JsonA = typeof (JsonA) === "string" ? JSON.parse(JsonA) : JsonA;
            var ids = [];
            JsonA.forEach((element, index) => {
                if (!!element.id) {
                    ids.push(element.id.replace(/\{|\}/g, ""));
                }
            });
            return ids.join(",");
        },
        /**
         * 输入框点击显示弹框选择数据 (前端分页)
         * Input多选添加类名 Multiple 
         * data-init=1||true:每次点击刷新表格
         * @param {选择框Input} InputId 
         * @param {其它输入项} Options 
         */
        InitSelectFn: function (InputId, Options) {
            var Defaults = {
                dataArr: [],//表格需要渲染的数据
                ColumnsSelf: [],//自定义渲染列表
                selectKey: "fundcode",//选择的Id ProductId
                selectName: "name",//选择的Name
                selectKeyOther: "",//选择的其它Id 
                selectNameOther: "fundcode",//选择的其它Name 可用于模糊查询
                modalTitle: "*请选择",//弹出框标题
                placeholderVal: "输入名称",//输入框placeholder
                modalClass: "selectModal750",//onlyShowTable 仅展示表格，隐藏已选列表
                removeIcon: `<svg class='iconSvg' aria-hidden='true'><use xlink:href='#iconshanchu'></use></svg>`,
                beforeClickFun: function () {
                    return true;
                },//点击先触发事件 true false
                submitFun: function () { },//弹窗提交按钮触发事件
                footerCreateBtnFn: function () { },//底部创建人点击触发事件
                showFooterCreateBtn: false,//是否展示底部创建人按钮  默认不展示
                showFooter: true,//是否展示底部按钮 默认展示
                showFooterSubmit: true,//是否展示底部submit按钮 默认展示
                cantCheckData: false,//仅展示数据不做选择 默认有选择框
                footerCreateBtnName: '创建机构',//底部按钮
                footerSubmitName: '确定',//底部按钮
                footerCancelName: '取消',//底部按钮
                pageSize: 10//分页数目默认10
            }
            var __this = this;
            __this[`mOpts${InputId}`] = $.extend({}, Defaults, Options);
            //表格选择
            let curSelectArr = [];
            //渲染弹框
            let ModalHtml = `
                <!-- ${__this[`mOpts${InputId}`].modalTitle}模态框（Modal） -->
                <div class="modal fade selectModal ${__this[`mOpts${InputId}`].modalClass}" id="selectModal${InputId}" tabindex="-1" role="dialog" aria-labelledby="selectTitle" aria-hidden="true" data-backdrop="false">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <button type="button" class="btn btn_active select_search_btn selectSearchBtn">搜索</button>
                                <input type="text" placeholder="${__this[`mOpts${InputId}`].placeholderVal}" class="selectSearchInput">
                                <h4 class="modal-title" id="selectTitle">${__this[`mOpts${InputId}`].modalTitle}</h4>
                            </div>
                            <div class="modal-body">
                                <div class="selectLoading" style="display:none;width:100%;padding:200px;">
                                    <span class="page_change_loading_wrap"><span class="page_change_loading_text"></span><span class="animation_wrap"><span class="page_change_dot"></span></span></span>
                                </div>
                                <div class="selectContent flexBetween">
                                    <table id="selectTable${InputId}" class="table-striped" style="table-layout:fixed;width: 100%;"></table>
                                    <div class="select-box new_scroll" style="
                                        ${__this[`mOpts${InputId}`].modalClass === 'onlyShowTable' ? 'display:none;' : ''}
                                        max-height:${ !__this[`mOpts${InputId}`].pageSize ? 12 * 30 : (Number(__this[`mOpts${InputId}`].pageSize) + 2) * 30}px;">
                                        <div class="select-title clearfix">
                                            <p class="fl selected">已选列表</p>
                                            <p class="fr removeAll">清空</p>
                                        </div>
                                        <ul class="select-ul" id="selectList${InputId}">
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer" style="${__this[`mOpts${InputId}`].showFooter ? '' : 'display:none;'}">
                                <button type="button" class="btn btn-default createOrgan" style="${__this[`mOpts${InputId}`].showFooterCreateBtn ? '' : 'display:none;'} width:82px;float:left;">${__this[`mOpts${InputId}`].footerCreateBtnName}</button>
                                <button type="button" class="btn btn_active selectSubmitBtn" style="${__this[`mOpts${InputId}`].showFooterSubmit ? '' : 'display:none;'}">${__this[`mOpts${InputId}`].footerSubmitName}</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">${__this[`mOpts${InputId}`].footerCancelName}</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>`;
            $("body").append(ModalHtml);
            //输入框点击显示弹框
            if ($(`#${InputId}`)[0].nodeName === "INPUT") {
                $(`#${InputId}`).unbind("blur").on("blur", function () {
                    if ($(this).val() == "") {
                        $(this).attr("data-selectid", "00");
                        $(`#selectModal${InputId} .selectSearchInput`).val("");
                        //重置列表
                        $(`#selectList${InputId}`).html("");
                        curSelectArr = [];
                        __this[`mOpts${InputId}`].dataArr = $.map(__this[`mOpts${InputId}`].dataArr, function (item) {
                            item.check = false;
                            return item;
                        });
                        $(`#selectTable${InputId}`).bootstrapTable("refreshOptions", {
                            data: __this[`mOpts${InputId}`].dataArr,
                            pageNumber: 1
                        });
                    }
                });
                // 初始化dom点击
                $(`#${InputId}`).unbind("click").on("click", function () {
                    // 带icon的input group
                    if ($(`#${InputId}`).parents(".iconInputGroup").length > 0 &&
                        ($(`#${InputId}`).parents(".iconInputGroup").hasClass("bgeee") || $(`#${InputId}`).parents(".iconInputGroup").hasClass("readonly"))
                    ) {
                        return;
                    }
                    if ($(`#${InputId}`).parents(".iconInputGroup").length > 0) {
                        $(`#${InputId}`).next().click(function () {
                            $(this).unbind("click");
                            $(`#${InputId}`).click();
                        });
                    }

                    if (!__this[`mOpts${InputId}`].beforeClickFun()) {
                        return;
                    };
                    let that = $(this);
                    Util.removeBottomText(`#selectTable${InputId}`);

                    // 点击初始化
                    if (that.attr("data-init") == "true" || that.attr("data-init") == "1") {
                        // 初始化表格
                        initSelectTable(__this[`mOpts${InputId}`].dataArr);
                    }

                    $(`#selectModal${InputId}`).modal("show");
                    // 提交按钮点击事件
                    $(`#selectModal${InputId} .selectSubmitBtn`).unbind("click").on("click", function () {
                        let sysuserVal = [], sysuserId = [], sysuserRows = [];
                        let allLi = $(`#selectList${InputId} li`);
                        for (let i = 0; i < allLi.length; i++) {
                            sysuserVal.push(allLi.eq(i).children("span").html());
                            sysuserId.push(allLi.eq(i).data("selectid"));
                            sysuserRows.push(allLi.eq(i).data("selectrow"));
                        }
                        that.val(sysuserVal.join(";"));
                        that.attr("title", sysuserVal.join(";"));
                        that.attr("data-selectid", sysuserId.join(","));
                        that.attr("data-selectrows", JSON.stringify(sysuserRows));
                        __this[`mOpts${InputId}`].submitFun(sysuserId, sysuserVal, sysuserRows);//提交后操作
                        $(`#selectModal${InputId}`).modal("hide");
                    });
                    // 是否添加点击事件
                    if( __this[`mOpts${InputId}`].showFooterCreateBtn ){
                        $(`#selectModal${InputId} .createOrgan`).on('click', __this[`mOpts${InputId}`].footerCreateBtnFn)
                    }
                });
                // 带icon的input group
                if ($(`#${InputId}`).parents(".iconInputGroup").length > 0) {
                    $(`#${InputId}`).next().click(function () {
                        $(`#${InputId}`).click();
                    });
                }
            } else {//按钮点击显示弹框
                $(`#${InputId}`).unbind("click").on("click", function () {
                    if (!__this[`mOpts${InputId}`].beforeClickFun()) {
                        return;
                    };
                    Util.removeBottomText(`#selectTable${InputId}`);

                    // 点击初始化
                    if ($(`#${InputId}`).attr("data-init") == "true" || $(`#${InputId}`).attr("data-init") == "1") {
                        // 初始化表格
                        initSelectTable(__this[`mOpts${InputId}`].dataArr);
                    }

                    $(`#selectModal${InputId}`).modal("show");
                    $(`#selectModal${InputId} .selectSubmitBtn`).unbind("click").on("click", function () {
                        let sysuserVal = [], sysuserId = [], sysuserRows = [];;
                        let allLi = $(`#selectList${InputId} li`);
                        for (let i = 0; i < allLi.length; i++) {
                            sysuserVal.push(allLi.eq(i).children("span").html());
                            sysuserId.push(allLi.eq(i).data("selectid"));
                            sysuserRows.push(allLi.eq(i).data("selectrow"));
                        }
                        __this[`mOpts${InputId}`].submitFun(sysuserId, sysuserVal, sysuserRows);
                        $(`#selectModal${InputId}`).modal("hide");
                    });
                });
            }

            // Id大写
            __this[`mOpts${InputId}`].dataArr.map(function (item, i) {
                if (!!__this[`mOpts${InputId}`].selectKey && !!item[__this[`mOpts${InputId}`].selectKey]) {
                    item[__this[`mOpts${InputId}`].selectKey] = item[__this[`mOpts${InputId}`].selectKey].toUpperCase();
                }
                if (!!__this[`mOpts${InputId}`].selectKeyOther && !!item[__this[`mOpts${InputId}`].selectKeyOther]) {
                    item[__this[`mOpts${InputId}`].selectKeyOther] = item[__this[`mOpts${InputId}`].selectKeyOther].toUpperCase();
                }

            });

            //初始化列表
            initSelectTable(__this[`mOpts${InputId}`].dataArr);
            function initSelectTable(dataArr, numberPage) {
                //初次打开时,反选
                if (!numberPage) {
                    $(`#selectList${InputId}`).html("");
                    curSelectArr = [];
                    dataArr.map((item, index) => {
                        item.check = false
                    });
                    let inputSelectId = !!$(`#${InputId}`).attr("data-selectid") ? $(`#${InputId}`).attr("data-selectid").toUpperCase() : "",
                        inputSelectName = $(`#${InputId}`)[0].nodeName === "INPUT" ? $(`#${InputId}`).val() : $(`#${InputId}`).attr("data-selectvalue"),
                        inputSelectRows = !!$(`#${InputId}`).attr("data-selectrows") ? $(`#${InputId}`).attr("data-selectrows") : "",
                        inputSelectIdArr = !!inputSelectId ? inputSelectId.split(",") : [],
                        inputSelectNameArr = !!inputSelectName ? inputSelectName.split(";") : [],
                        inputSelectRowsArr = !!inputSelectRows ? JSON.parse(inputSelectRows) : [];
                    if (!!inputSelectId && inputSelectId !== "00" && inputSelectIdArr.length > 0) {//有选择项时再反选
                        let addMenHtmlPage = "";
                        inputSelectIdArr.forEach((item, index) => {
                            addMenHtmlPage += `<li data-selectid ='${item}' data-selectrow='${JSON.stringify(inputSelectRowsArr[index])}'><span class="ellipsis_pLeft" title="${inputSelectNameArr[index]}">${inputSelectNameArr[index]}</span><a class='remove_manager' href='javascript:void(0)' title='Remove'>${__this[`mOpts${InputId}`].removeIcon}</a></li>`;
                        });
                        $(`#selectList${InputId}`).append(addMenHtmlPage);
                        curSelectArr = curSelectArr.concat(inputSelectIdArr);//选择的Id
                        dataArr.map((item, index) => {
                            item.check = false
                            curSelectArr.map((itemS, indexS) => {
                                if (item[__this[`mOpts${InputId}`].selectKey] === itemS) {
                                    item.check = true
                                }
                            })
                        });
                    }
                }
                var $SelectTable = $(`#selectTable${InputId}`);
                $SelectTable.bootstrapTable('destroy').bootstrapTable({
                    strip: "true",
                    pagination: "true",
                    pageSize: __this[`mOpts${InputId}`].pageSize,
                    pageNumber: numberPage ? numberPage : 1,
                    singleSelect: $(`#${InputId}`).hasClass("Multiple") ? false : true,
                    clickToSelect: __this[`mOpts${InputId}`].cantCheckData ? false : true,
                    sidePagination: "client",
                    data: dataArr,
                    totalRows: dataArr.length,
                    columns: [
                        __this[`mOpts${InputId}`].ColumnsSelf
                    ],
                    onCheck: function (row) {
                        if (!$(`#${InputId}`).hasClass("Multiple")) {//Multiple 多选
                            curSelectArr = [];
                            $(`#selectList${InputId}`).html("");
                        }
                        curSelectArr.push(row[__this[`mOpts${InputId}`].selectKey]);//选择的Id
                        let addMenHtml = `<li data-selectid ='${row[__this[`mOpts${InputId}`].selectKey]}' data-selectrow='${JSON.stringify(row)}'><span class="ellipsis_pLeft" title="${row[__this[`mOpts${InputId}`].selectName]}">${row[__this[`mOpts${InputId}`].selectName]}</span><a class='remove_manager' href='javascript:void(0)' title='Remove'>${__this[`mOpts${InputId}`].removeIcon}</a></li>`;
                        $(`#selectList${InputId}`).append(addMenHtml);
                    },
                    onUncheck: function (row) {
                        if (curSelectArr.indexOf(row[__this[`mOpts${InputId}`].selectKey]) !== -1) {
                            curSelectArr.splice(curSelectArr.indexOf(row[__this[`mOpts${InputId}`].selectKey]), 1);
                        }
                        for (let i in $(`#selectList${InputId} li`)) {
                            if (row[__this[`mOpts${InputId}`].selectKey] == $(`#selectList${InputId} li`).eq(i).data("selectid")) {
                                $(`#selectList${InputId} li`).eq(i).remove();
                            }
                        }
                    },
                    onCheckAll: function (rowsAfter) {
                        // 选择当页全部
                        rowsAfter.map((item, i) => {
                            let curId = item[__this[`mOpts${InputId}`].selectKey];
                            if (curSelectArr.indexOf(curId) === -1) {
                                curSelectArr.push(curId);
                                let addMenHtml = `<li data-selectid ='${item[__this[`mOpts${InputId}`].selectKey]}' data-selectrow='${JSON.stringify(item)}'><span class="ellipsis_pLeft" title="${item[__this[`mOpts${InputId}`].selectName]}">${item[__this[`mOpts${InputId}`].selectName]}</span><a class='remove_manager' href='javascript:void(0)' title='Remove'>${__this[`mOpts${InputId}`].removeIcon}</a></li>`;
                                $(`#selectList${InputId}`).append(addMenHtml);
                            }
                        })
                    },
                    onUncheckAll: function (rowsAfter, rowsBefore) {
                        // 删除当页全部
                        let idsAfter = [];//取消勾选后的id数据
                        let copyCurData = JSON.parse(JSON.stringify(curSelectArr));//当前已选数据
                        rowsAfter.map(item => {
                            idsAfter.push(item[__this[`mOpts${InputId}`].selectKey]);
                        });
                        copyCurData.forEach((item, i) => {
                            if (idsAfter.indexOf(item) === -1) {
                                curSelectArr.splice(curSelectArr.indexOf(item), 1);
                            }
                        })
                        // 删除选择内容
                        $(`#selectList${InputId} li`).each(function (e) {
                            // 选择的数据中删除
                            if (curSelectArr.indexOf($(this).data("selectid")) === -1) {
                                $(this).remove();
                            }
                        });
                    }
                });
                $SelectTable.on("page-change.bs.table", function (e, number, size) {
                    refreshPageData(number)
                });
                Util.removeBottomText(`#selectTable${InputId}`);
                $SelectTable.on('click-row.bs.table', function ($e, row, tr) {
                    console.log("row:", row);
                })
                $SelectTable.on('all.bs.table', function (e, name, args) {
                    Util.removeBottomText(`#selectTable${InputId}`);
                });
                // 带icon的input group
                if ($(`#${InputId}`).parents(".iconInputGroup").length > 0) {
                    $(`#${InputId}`).parents(".iconInputGroup").removeClass("bgeee");
                } else {
                    $(`#${InputId}`).attr("disabled", false);
                }
            }
            function refreshPageData(number) {
                let $SelectTable = $(`#selectTable${InputId}`);
                let dataArr = $SelectTable.bootstrapTable("getData");
                dataArr = $.map(dataArr, function (value) {
                    for (let i in curSelectArr) {
                        if (curSelectArr[i] == value[__this[`mOpts${InputId}`].selectKey]) {
                            value.check = true;
                        }
                    }
                    return value;
                });
                $SelectTable.bootstrapTable("refreshOptions", {
                    data: dataArr,
                    pageNumber: number
                });
            }
            //删除联系人 点击已选联系人删除按钮
            $(`#selectList${InputId}`).unbind("click").on("click", ".remove_manager", function () {
                var that = $(this);
                var delId = $(this).parent().data("selectid");
                if (curSelectArr.indexOf(delId) !== -1) {
                    curSelectArr.splice(curSelectArr.indexOf(delId), 1);
                }
                that.parent().remove();
                var curData = $(`#selectTable${InputId}`).bootstrapTable("getData");
                curData.map((item, i) => {
                    if (item[__this[`mOpts${InputId}`].selectKey] == delId) {
                        item.check = false;
                        for (let j in $(`#selectTable${InputId} tbody tr`)) {
                            if ($(`#selectTable${InputId} tbody tr`).eq(j).data("index") == i) {
                                $(`#selectTable${InputId} tbody tr`).eq(j).removeClass("selected").find(".bs-checkbox input").removeAttr("checked");
                                $(`#selectTable${InputId} thead tr`).eq(0).find(".bs-checkbox input").removeAttr("checked");
                                return;
                            }
                        }
                    }
                });
            })
            $(`#selectModal${InputId} .selectSearchInput`).unbind("keyup").on("keyup", function (e) {
                Util.stopEvent(e);
                var e = e || window.event;
                if (e.keyCode == 13) {//enter键
                    let selectKeyArr = [], keywords = $(this).val();
                    __this[`mOpts${InputId}`].dataArr.map(function (item) {
                        // 代码或名称模糊搜索
                        if (!item || !item[__this[`mOpts${InputId}`].selectName]) {
                            console.log(`列表数据搜索值：`, item);
                        } else if (item[__this
                        [`mOpts${InputId}`].selectName].toUpperCase().indexOf(keywords.toUpperCase()) != -1 || (item[__this[`mOpts${InputId}`].selectNameOther] && item[__this[`mOpts${InputId}`].selectNameOther].toUpperCase().indexOf(keywords.toUpperCase()) != -1)) {
                            selectKeyArr.push(item);
                        }
                    });
                    initSelectTable(selectKeyArr, 1);
                }
            });
            $(`#selectModal${InputId} .selectSearchBtn`).unbind("click").on("click", function () {
                let selectKeyArr = [], keywords = $(`#selectModal${InputId} .selectSearchInput`).val();
                __this[`mOpts${InputId}`].dataArr.map(function (item) {
                    // 代码或名称模糊搜索
                    if (!item || !item[__this[`mOpts${InputId}`].selectName]) {
                        console.log(`列表数据搜索值：`, item);
                    } else if (item[__this
                    [`mOpts${InputId}`].selectName].toUpperCase().indexOf(keywords.toUpperCase()) != -1 || (item[__this[`mOpts${InputId}`].selectNameOther] && item[__this[`mOpts${InputId}`].selectNameOther].toUpperCase().indexOf(keywords.toUpperCase()) != -1)) {
                        selectKeyArr.push(item);
                    }
                });
                initSelectTable(selectKeyArr, 1);
            });
            $(`#selectModal${InputId} .removeAll`).unbind("click").on("click", function () {
                curSelectArr = [];
                $(`#selectList${InputId}`).html("");
                $(`#selectTable${InputId} thead tr`).eq(0).find(".bs-checkbox input").removeAttr("checked");
                $(`#selectTable${InputId} tbody tr.selected`).each(function (e) {
                    // $(this).removeClass("selected").find(".bs-checkbox input").removeAttr("checked");
                    $(this).removeClass("selected").find(".bs-checkbox input")[0].checked = false
                });
            });
        },
        /**
         * 输入框点击显示弹框选择数据
         *  (后端分页)
         * @param {选择框Input} InputId 多选Input添加类名Multiple
         * @param {其它输入项} Options 
         */
        InitSelectFnPageByServer: function (InputId, Options) {
            var Defaults = {
                url: "/api/data/v8.2/new_MainAction",//默认Action 产品选择是360
                paramsJson360: {},//360接口时传参
                interfaceCode: "",//接口名
                paramsJson: {},//接口传参
                pageParamIsObj: true,//分页参数是不是对象
                pageAskName: "page",//分页请求参数名
                pageAskIndexName: "PageIndex",//分页请求参数名 页码
                pageAskSizeName: "PageSize",//分页请求参数名 数目
                dataCountName: "totalNumber",//数据总数 字段名
                dataListName: "Rows",//数据数组 字段名
                pageSize: "10",//每页数目
                removeIcon: `<svg class='iconSvg' aria-hidden='true'><use xlink:href='#iconshanchu'></use></svg>`,
                responseHandlerFun: function (res) {
                    // 带icon的input group
                    if ($(`#${InputId}`).parents(".iconInputGroup").length > 0) {
                        $(`#${InputId}`).parents(".iconInputGroup").removeClass("bgeee");
                        $(`#${InputId}`).next().click(function () {
                            $(`#${InputId}`).click();
                        });
                    } else {
                        $(`#${InputId}`).attr("disabled", false);
                    }
                    var outPutMsg = JSON.parse(res.OutMsg);
                    if (!outPutMsg.data || outPutMsg.data[__this[`mOpts${InputId}`].dataListName].length == 0 || outPutMsg.code != 1) {
                        return {
                            "total": 0,
                            "rows": []
                        }
                    }
                    var tableData = outPutMsg.data;
                    // 分页信息可能是个对象，也可能是与list同级的字段
                    if (__this[`mOpts${InputId}`].dataCountName.indexOf(".") != -1) {
                        return {
                            "total": tableData[__this[`mOpts${InputId}`].dataCountName.split(".")[0]][__this[`mOpts${InputId}`].dataCountName.split(".")[1]],
                            "rows": tableData[__this[`mOpts${InputId}`].dataListName]
                        }
                    }
                    return {
                        "total": tableData[__this[`mOpts${InputId}`].dataCountName],
                        "rows": tableData[__this[`mOpts${InputId}`].dataListName]
                    }
                },
                hasSearch: true,//是否可以模糊搜索
                searchInputSelf: [],//自定义多个搜索项
                beforeSearchFn: function () { return true; },//查询前方法，如：必输项等
                ColumnsSelf: [],//自定义渲染列表，field: 'check'选择列不传（产品选择可以不传ColumnsSelf）
                selectKey: "productId",//选择的Id
                selectName: "name",//选择的Name
                searchName: "",//模糊查询接口传参的key
                selectKeyOther: "",//选择的其它Id
                modalTitle: "*请选择产品",//弹出框标题
                placeholderVal: "输入产品名称",//输入框placeholder
                modalClass: "selectModal750",
                beforeClickFun: function () { return true; },//点击先触发事件 true false
                submitFun: function () { },//弹窗提交按钮触发事件
                firstViewDontSearch: false//打开弹窗不查询数据,默认查询
            }
            var __this = this;
            __this[`mOpts${InputId}`] = $.extend({}, Defaults, Options);
            // 查询名称没有则默认为selectname
            if (!__this[`mOpts${InputId}`].searchName) {
                __this[`mOpts${InputId}`].searchName = __this[`mOpts${InputId}`].selectName;
            }
            // 表格列
            if (!!Options.ColumnsSelf && Options.ColumnsSelf.length === 0) {
                __this[`mOpts${InputId}`].ColumnsSelf = [
                    {
                        field: 'check', checkbox: true, width: '10%', formatter: function (val, row, index) {
                            for (let i in curSelectArr) {
                                if (curSelectArr[i] === row[__this[`mOpts${InputId}`].selectKey]) {
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        }
                    }, { title: '产品代码', field: 'fundcode', align: 'center', width: '25%', formatter: Util.FormatterEllipsis },
                    { title: '产品名称', field: 'name', align: 'center', width: '40%', formatter: Util.FormatterEllipsis },
                    { title: '产品类型', field: 'investtarget', align: 'center', width: '25%', formatter: Util.FormatterEllipsis }]
            } else {
                __this[`mOpts${InputId}`].ColumnsSelf = [
                    {
                        field: 'check', checkbox: true, width: '10%', formatter: function (val, row, index) {
                            for (let i in curSelectArr) {
                                if (curSelectArr[i] === row[__this[`mOpts${InputId}`].selectKey]) {
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        }
                    }].concat(Options.ColumnsSelf);
            }
            //表格选择
            var curSelectArr = [];//选择的数据
            // 自定义搜索框代码
            if (__this[`mOpts${InputId}`].hasSearch && __this[`mOpts${InputId}`].searchInputSelf.length > 0) {
                let inputSelfHtml = `<button type="button" class="btn btn_active select_search_btn selectSearchBtn">搜索</button>`
                __this[`mOpts${InputId}`].searchInputSelf.forEach((item, i) => {
                    if (item.must) {
                        inputSelfHtml += `<div class="inputBox fr"><span class="redStar">*</span><label for="selectSearch${item.key}">${item.name}:</label><input type="text" id="selectSearch${item.key}" placeholder="${item.placeholder}" class="selectSearchInput"></div>`;
                    } else {
                        inputSelfHtml += `<div class="inputBox fr"><label for="selectSearch${item.key}">${item.name}:</label><input type="text" id="selectSearch${item.key}" placeholder="${item.placeholder}" class="selectSearchInput"></div>`;
                    }
                });
                __this[`mOpts${InputId}`].searchInputSelfHtml = inputSelfHtml;
            }
            //渲染弹框
            let ModalHtml = `
                <!-- ${__this[`mOpts${InputId}`].modalTitle}模态框（Modal） -->
                <div class="modal fade selectModal ${__this[`mOpts${InputId}`].modalClass}" id="selectModal${InputId}" tabindex="-1" role="dialog" aria-labelledby="selectTitle" aria-hidden="true" data-backdrop="false">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                ${
                __this[`mOpts${InputId}`].hasSearch ?
                    (!!__this[`mOpts${InputId}`].searchInputSelfHtml ?
                        __this[`mOpts${InputId}`].searchInputSelfHtml
                        :
                        `<button type="button" class="btn btn_active select_search_btn selectSearchBtn">搜索</button>
                                    <input type="text" placeholder="${__this[`mOpts${InputId}`].placeholderVal}" class="selectSearchInput">`)
                    :
                    ``
                }
                                <h4 class="modal-title" id="selectTitle">${__this[`mOpts${InputId}`].modalTitle}</h4>
                            </div>
                            <div class="modal-body">
                                <div class="selectLoading" style="display:none;width:100%;padding:200px;">
                                    <span class="page_change_loading_wrap"><span class="page_change_loading_text"></span><span class="animation_wrap"><span class="page_change_dot"></span></span></span>
                                </div>
                                <div class="selectContent flexBetween">
                                    <table id="selectTable${InputId}" class="table-striped" style="table-layout:fixed;width: 100%;height:100%"></table>
                                    <div class="select-box new_scroll" style="max-height:${ !__this[`mOpts${InputId}`].pageSize ? 500 : (Number(__this[`mOpts${InputId}`].pageSize) + 2) * 30}px">
                                        <div class="select-title clearfix">
                                            <p class="fl selected">已选列表</p>
                                            <p class="fr removeAll">清空</p>
                                        </div>
                                        <ul class="select-ul" id="selectList${InputId}">
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn_active selectSubmitBtn">确定</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>`;
            $("body").append(ModalHtml);
            //输入框点击显示弹框
            if ($(`#${InputId}`)[0].nodeName === "INPUT") {
                $(`#${InputId}`).unbind("click").on("click", function () {
                    if (!__this[`mOpts${InputId}`].beforeClickFun()) {
                        return;
                    };
                    let that = $(this);
                    Util.removeBottomText(`#selectTable${InputId}`);
                    $(`#selectModal${InputId}`).modal("show");
                    $(`#selectModal${InputId} .selectSubmitBtn`).unbind("click").on("click", function () {
                        let sysuserVal = [], sysuserId = [];
                        let allLi = $(`#selectList${InputId} li`);
                        for (let i = 0; i < allLi.length; i++) {
                            sysuserVal.push(allLi.eq(i).children("span").html());
                            sysuserId.push(allLi.eq(i).data("selectid"));
                        }
                        that[0].value = sysuserVal.join(";");
                        that.attr("title", sysuserVal.join(";"));
                        that.attr("data-selectid", sysuserId.join(","));
                        __this[`mOpts${InputId}`].submitFun(sysuserId, sysuserVal);//提交后操作
                        $(`#selectModal${InputId}`).modal("hide");
                    });
                });
            } else {//按钮点击显示弹框
                $(`#${InputId}`).unbind("click").on("click", function () {
                    if (!__this[`mOpts${InputId}`].beforeClickFun()) {
                        return;
                    };
                    Util.removeBottomText(`#selectTable${InputId}`);
                    $(`#selectModal${InputId}`).modal("show");
                    $(`#selectModal${InputId} .selectSubmitBtn`).unbind("click").on("click", function () {
                        let sysuserVal = [], sysuserId = [];
                        let allLi = $(`#selectList${InputId} li`);
                        for (let i = 0; i < allLi.length; i++) {
                            sysuserVal.push(allLi.eq(i).children("span").html());
                            sysuserId.push(allLi.eq(i).data("selectid"));
                        }
                        if (sysuserId.length > 0) {
                            __this[`mOpts${InputId}`].submitFun(sysuserId, sysuserVal);//提交后操作
                            $(`#selectModal${InputId}`).modal("hide");
                        } else {
                            Util.BootstrapDialogAlert(__this[`mOpts${InputId}`].modalTitle);
                        }
                    });
                });
            }

            //初始化列表

            if (__this[`mOpts${InputId}`].firstViewDontSearch) {
                initSelectTableNull();
            } else {

                initSelectTable();
            }
            function initSelectTable(numberPage) {
                var $SelectTable = $(`#selectTable${InputId}`);
                $SelectTable.bootstrapTable('destroy').bootstrapTable({
                    strip: "true",
                    pagination: "true",
                    pageSize: __this[`mOpts${InputId}`].pageSize,
                    pageNumber: numberPage ? numberPage : 1,
                    singleSelect: $(`#${InputId}`).hasClass("Multiple") ? false : true,
                    clickToSelect: true,
                    sidePagination: "server",
                    method: "POST",
                    contentType: "application/json",
                    url: __this[`mOpts${InputId}`].url,//"/api/data/v8.2/htf_action_360"  "/api/data/v8.2/new_MainAction"
                    queryParams: JSON.stringify(
                        __this[`mOpts${InputId}`].url.indexOf("htf_action_360") === -1 ?
                            {
                                InMsg: JSON.stringify({
                                    new_interface_code: __this[`mOpts${InputId}`].interfaceCode,
                                    new_params: JSON.stringify(__this[`mOpts${InputId}`].paramsJson)
                                })
                            } :
                            { input: JSON.stringify(__this[`mOpts${InputId}`].paramsJson360) }
                    ),
                    responseHandler: __this[`mOpts${InputId}`].responseHandlerFun,
                    onLoadSuccess: function () {
                        Util.removeBottomText(`#selectTable${InputId}`);
                    },
                    cache: false,
                    columns: [
                        __this[`mOpts${InputId}`].ColumnsSelf
                    ],
                    onCheck: function (row) {
                        if (!$(`#${InputId}`).hasClass("Multiple")) {//Multiple 多选
                            curSelectArr = [];
                            $(`#selectList${InputId}`).html("");
                        }
                        curSelectArr.push(row[__this[`mOpts${InputId}`].selectKey]);//选择的产品Id
                        if (__this[`mOpts${InputId}`].selectKeyOther) {
                            let addMenHtml = `<li data-selectid ='${row[__this[`mOpts${InputId}`].selectKey]}'  data-selectid2 ='${row[__this[`mOpts${InputId}`].selectKeyOther]}'><span class="ellipsis_pLeft" title="${row[__this[`mOpts${InputId}`].selectName]}">${row[__this[`mOpts${InputId}`].selectName]}</span><a class='remove_manager' href='javascript:void(0)' title='Remove'>${__this[`mOpts${InputId}`].removeIcon}</a></li>`;
                            $(`#selectList${InputId}`).append(addMenHtml);
                        } else {
                            let addMenHtml = `<li data-selectid ='${row[__this[`mOpts${InputId}`].selectKey]}'><span class="ellipsis_pLeft" title="${row[__this[`mOpts${InputId}`].selectName]}">${row[__this[`mOpts${InputId}`].selectName]}</span><a class='remove_manager' href='javascript:void(0)' title='Remove'>${__this[`mOpts${InputId}`].removeIcon}</a></li>`;
                            $(`#selectList${InputId}`).append(addMenHtml);
                        }
                    },
                    onUncheck: function (row) {
                        if (curSelectArr.indexOf(row[__this[`mOpts${InputId}`].selectKey]) !== -1) {
                            curSelectArr.splice(curSelectArr.indexOf(row[__this[`mOpts${InputId}`].selectKey]), 1);
                        }
                        for (let i in $(`#selectList${InputId} li`)) {
                            if (row[__this[`mOpts${InputId}`].selectKey] == $(`#selectList${InputId} li`).eq(i).data("selectid")) {
                                $(`#selectList${InputId} li`).eq(i).remove();
                            }
                        }
                    }
                });
                $SelectTable.on("page-change.bs.table", function (e, number, size) {
                    reloadSelectTable(number);
                });
                if ($(`#${InputId}`).hasClass("Multiple") && $(`#selectTable${InputId} thead input`).length > 0) {//Multiple 多选
                    $(`#selectTable${InputId} thead input`).remove();
                }
                $SelectTable.on('all.bs.table', function (e, name, args) {
                    Util.removeBottomText(`#selectTable${InputId}`);
                    if ($(`#${InputId}`).hasClass("Multiple") && $(`#selectTable${InputId} thead input`).length > 0) {//Multiple 多选
                        $(`#selectTable${InputId} thead input`).remove();
                    }
                });
                //删除联系人 点击已选联系人删除按钮
                $(`#selectList${InputId}`).unbind("click").on("click", ".remove_manager", function () {
                    var that = $(this);
                    var delId = $(this).parent().data("selectid");
                    if (curSelectArr.indexOf(delId) !== -1) {
                        curSelectArr.splice(curSelectArr.indexOf(delId), 1);
                    }
                    var curData = $(`#selectTable${InputId}`).bootstrapTable("getData");
                    that.parent().remove();
                    for (let i in curData) {
                        if (curData[i][__this[`mOpts${InputId}`].selectKey] == delId) {
                            for (let j in $(`#selectTable${InputId} tbody tr`)) {
                                if ($(`#selectTable${InputId} tbody tr`).eq(j).data("index") == i) {
                                    $(`#selectTable${InputId} tbody tr`).eq(j).removeClass("selected").find(".bs-checkbox input").removeAttr("checked");
                                    if ($(`#selectList${InputId} li`).length == 0) {//没有选择的联系人 去掉全选
                                        $(`#selectTable${InputId} thead tr`).eq(0).find(".bs-checkbox input").removeAttr("checked");
                                    }
                                    return;
                                }
                            }
                        }
                    }
                })
                $(`#selectModal${InputId} .removeAll`).unbind("click").on("click", function () {
                    curSelectArr = [];
                    $(`#selectList${InputId}`).html("");
                    $(`#selectTable${InputId} tbody tr`).each(function (e) {
                        $(this).removeClass("selected").find(".bs-checkbox input").removeAttr("checked");
                    });
                });

            }
            // 置空
            function initSelectTableNull() {
                var $SelectTable = $(`#selectTable${InputId}`);
                $SelectTable.bootstrapTable('destroy').bootstrapTable({
                    data: [],
                    cache: false,
                    columns: [
                        __this[`mOpts${InputId}`].ColumnsSelf
                    ]
                });
            }
            // 有模糊搜索时添加模糊搜索方法
            if (__this[`mOpts${InputId}`].hasSearch) {
                $(`#selectModal${InputId} .selectSearchInput`).unbind("keyup").on("keyup", function (e) {
                    Util.stopEvent(e);
                    var e = e || window.event;
                    if (e.keyCode == 13) {//enter键
                        let keywords = $(this).val();
                        let toggleSearch = __this[`mOpts${InputId}`].beforeSearchFn();
                        if (__this[`mOpts${InputId}`].url.indexOf("htf_action_360") === -1) {
                            // 自定义多个搜索项,并通过校验
                            if (__this[`mOpts${InputId}`].searchInputSelf.length > 0 && toggleSearch) {
                                __this[`mOpts${InputId}`].searchInputSelf.forEach((item, i) => {
                                    __this[`mOpts${InputId}`].paramsJson[item.key] = $(`#selectSearch${item.key}`).val();
                                });
                                // 修改分页参数
                                if (__this[`mOpts${InputId}`].pageAskName && __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName]) {
                                    __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName][__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                                }
                                //Action分页参数也可能不放在对象里
                                if (!__this[`mOpts${InputId}`].pageParamIsObj) {
                                    __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                                }
                                // 360分页参数不是放在一个
                                对象里
                                if (__this[`mOpts${InputId}`].paramsJson360 && __this[`mOpts${InputId}`].pageAskIndexName) {
                                    __this[`mOpts${InputId}`].paramsJson360[__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                                }
                                initSelectTable(1);
                                return;
                            } else {//默认搜索项
                                __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].searchName] = keywords
                            }
                        } else {
                            __this[`mOpts${InputId}`].paramsJson360[__this[`mOpts${InputId}`].searchName] = keywords
                        }
                        if (toggleSearch) {
                            // 初始化表格
                            reloadSelectTable(1);
                        }
                    }
                });
                $(`#selectModal${InputId} .selectSearchBtn`).unbind("click").on("click", function () {
                    let keywords = $(`#selectModal${InputId} .selectSearchInput`).val();
                    let toggleSearch = __this[`mOpts${InputId}`].beforeSearchFn();
                    if (__this[`mOpts${InputId}`].url.indexOf("htf_action_360") === -1) {
                        // 自定义多个搜索项,并通过校验
                        if (__this[`mOpts${InputId}`].searchInputSelf.length > 0 && toggleSearch) {
                            __this[`mOpts${InputId}`].searchInputSelf.forEach((item, i) => {
                                __this[`mOpts${InputId}`].paramsJson[item.key] = $(`#selectSearch${item.key}`).val();
                            });
                            if (!__this[`mOpts${InputId}`].pageParamIsObj) {
                                __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                            }
                            // 修改分页参数
                            if (__this[`mOpts${InputId}`].pageAskName && __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName]) {
                                __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName][__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                            }
                            //Action分页参数也可能不放在对象里
                            if (!__this[`mOpts${InputId}`].pageParamIsObj) {
                                __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                            }
                            // 360分页参数不是放在一个对象里
                            if (__this[`mOpts${InputId}`].paramsJson360 && __this[`mOpts${InputId}`].pageAskIndexName) {
                                __this[`mOpts${InputId}`].paramsJson360[__this[`mOpts${InputId}`].pageAskIndexName] = 1;
                            }
                            initSelectTable(1);
                            return;
                        } else {//默认搜索项
                            __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].searchName] = keywords
                        }
                    } else {
                        __this[`mOpts${InputId}`].paramsJson360[__this[`mOpts${InputId}`].searchName] = keywords
                    }
                    if (toggleSearch) {
                        // 初始化表格
                        reloadSelectTable(1);
                    }
                });
            }
            //翻页后重新加载
            function reloadSelectTable(number) {
                // 修改分页参数
                if (__this[`mOpts${InputId}`].pageAskName && __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName]) {
                    __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskName][__this[`mOpts${InputId}`].pageAskIndexName] = number;
                }
                //Action分页参数也可能不放在对象里
                if (!__this[`mOpts${InputId}`].pageParamIsObj) {
                    __this[`mOpts${InputId}`].paramsJson[__this[`mOpts${InputId}`].pageAskIndexName] = number;
                }
                // 360分页参数不是放在一个对象里
                if (__this[`mOpts${InputId}`].paramsJson360 && __this[`mOpts${InputId}`].pageAskIndexName) {
                    __this[`mOpts${InputId}`].paramsJson360[__this[`mOpts${InputId}`].pageAskIndexName] = number;
                }
                var $SelectTable = $(`#selectTable${InputId}`);
                $SelectTable.bootstrapTable("refreshOptions", {
                    queryParams: JSON.stringify(
                        __this[`mOpts${InputId}`].url.indexOf("htf_action_360") === -1 ?
                            {
                                InMsg: JSON.stringify({
                                    new_interface_code: __this[`mOpts${InputId}`].interfaceCode,
                                    new_params: JSON.stringify(__this[`mOpts${InputId}`].paramsJson)
                                })
                            } :
                            { input: JSON.stringify(__this[`mOpts${InputId}`].paramsJson360) },
                    ),
                    pageNumber: number,
                    formatNoMatches: function () {
                        return "<span class=\"page_change_loading_wrap\"><span class=\"page_change_loading_text\">正在努力地加载数据中，请稍候</span><span class=\"animation_wrap\"><span class=\"page_change_dot\"></span></span></span>"
                    },
                    onLoadSuccess: function (data) {
                        if (data.rows.length == 0) {
                            $(`#selectTable${InputId} .no-records-found td`).html("没有找到匹配的记录");
                        }
                    }
                });
            }
        },
        /**
         * 模糊下拉搜索
         * @param {所有下拉选项  键值对的形式} AllDroupData 可能是数组，可能是{id:name,...}
         * @param {模糊查询input的id} DomId 
         * @param {下拉列表的类名class} DroupListDom 
         */
        InitSearchDroupDownFn: function (AllDroupData, DomId, DroupListDom, idKeyIn, nameKeyIn) {
            // idKey nameKey 数据为对象时，可以不传指定的Id名称和Name
            var idKey = idKeyIn || "Id";
            var nameKey = nameKeyIn || "Name";
            var NameBefore = "", NameNow = "";
            $("#" + DomId).on("focus", function () {
                NameBefore = $(this).val();
                //显示一键删除按钮
                $(this).next().removeClass("iconxiajiantou").removeClass("iconshangjiantou").addClass("iconguanbi");
                let val = $(this).val();
                getChannel($(this).parents(".dropdown_box").find(".dropdown_menu"), val);
            });
            $("#" + DomId).on("keyup", function (e) {
                let val = $(this).val(), that = $(this);
                var e = e || window.event;
                if (e.keyCode == 13) {//enter键
                    let LiDom = $(this).parents(".dropdown_box").find(".dropdown_menu li.active");
                    if (LiDom.length > 0) {
                        $(this).val(LiDom[0].innerHTML).attr("data-selectid", LiDom[0].dataset.id);
                    } else {
                        $(this).val("").attr("data-selectid", "00");
                    }
                    that.next().removeClass("iconshangjiantou").addClass("iconxiajiantou");
                    that.parent().next().hide();
                    $(this).blur();
                } else if (e.keyCode == 38) {//上键
                    let LiDomA = $(this).parents(".dropdown_box").find(".dropdown_menu li.active");
                    if (LiDomA.length > 0) {
                        let idxAct = $(this).parents(".dropdown_box").find(".dropdown_menu li.active").index();
                        if ((idxAct - 1) >= 0) {
                            $(this).parents(".dropdown_box").find(".dropdown_menu li").removeClass("active").eq(idxAct - 1).addClass("active");
                        }
                    }
                } else if (e.keyCode == 40) {//下键
                    let LiDomA = $(this).parents(".dropdown_box").find(".dropdown_menu li.active");
                    let LiDom = $(this).parents(".dropdown_box").find(".dropdown_menu li");
                    if (LiDomA.length > 0) {
                        let idxAct = $(this).parents(".dropdown_box").find(".dropdown_menu li.active").index();
                        if ((idxAct + 1) < LiDom.length) {
                            $(this).parents(".dropdown_box").find(".dropdown_menu li").removeClass("active").eq(idxAct + 1).addClass("active");
                        }
                    } else if (LiDom.length > 0) {
                        $(this).parents(".dropdown_box").find(".dropdown_menu li").removeClass("active").eq(0).addClass("active");
                    }
                } else {
                    getKeyUpChannel($(this).parents(".dropdown_box").find(".dropdown_menu"), val);
                }
            });
            //一键清除按钮的操作
            $("#" + DomId).next().on("mouseover", function () {
                $("#" + DomId).unbind("blur");
            });
            $("#" + DomId).next().on("mouseleave", function () {
                SearchInputBlur();
            });
            $("#" + DomId).next().on("click", function () {
                if (!$(this).hasClass("iconguanbi")) {
                    $("i.iconguanbi").removeClass("iconguanbi").addClass("iconxiajiantou");
                    $(".dropdown_box .dropdown_menu").hide();
                    $(this).prev().focus();
                    return;
                }
                $(this).removeClass("iconguanbi").addClass("iconxiajiantou");
                $(this).prev().val("").attr("data-selectid", "00").parents(".dropdown_box").find(".dropdown_menu").hide();
            });
            // 下拉选项hover事件
            $("." + DroupListDom).on("mouseover", "li", function () {
                $("#" + DomId).unbind("blur");
                $(this).addClass("active").siblings().removeClass("active");
            });
            $("." + DroupListDom).on("mouseleave", "li", function () {
                SearchInputBlur();
            });
            $("." + DroupListDom).on("click", "li", function () {
                let curlihtml = $(this).html(),
                    curliid = $(this)[0].dataset.id;
                $(this).parents(".dropdown_box").find("#" + DomId).val(curlihtml).attr("data-selectid", curliid);
                $(this).parents(".dropdown_box").find("i").removeClass("iconguanbi").addClass("iconxiajiantou");
                $(this).parents(".dropdown_box").find(".dropdown_menu").hide();
            });
            SearchInputBlur();
            function SearchInputBlur() {
                $("#" + DomId).on("blur", function () {
                    NameNow = $(this).val();
                    let val = $(this).val(), that = $(this);
                    that.parent().next().hide();
                    //显示下箭头
                    that.next().removeClass("iconguanbi").addClass("iconxiajiantou");
                    //如果内容不发生变化，则不请求下级别内容
                    if (NameNow === NameBefore) {
                        return;
                    }
                    if (val == "") {
                        $(this).attr("data-selectid", "00");
                        return;
                    }
                    let LiDom = $(this).parents(".dropdown_box").find(".dropdown_menu li.active");
                    if (LiDom.length > 0) {
                        $(this).val(LiDom[0].innerHTML).attr("data-selectid", LiDom[0].dataset.id);
                    } else {
                        $(this).val("").attr("data-selectid", "00");
                    }
                });
            }
            //失焦和回车时，填充对应符合的字段
            function getChannel(dom, val) {
                let menuHtml = '', AllDroupDataObj = {};
                if (Array.isArray(AllDroupData)) {
                    AllDroupData.map(function (item, index) {
                        AllDroupDataObj[item[idKey]] = item[nameKey];
                    });
                } else {
                    AllDroupDataObj = AllDroupData;
                }
                for (let i in AllDroupDataObj) {
                    if (val == "") {
                        menuHtml += `<li title="${AllDroupDataObj[i]}" data-value="${AllDroupDataObj[i]}" data-id="${i}">${AllDroupDataObj[i]}</li>`;
                    } else if (AllDroupDataObj[i].indexOf(val) != -1) {
                        menuHtml += `<li title="${AllDroupDataObj[i]}" data-value="${AllDroupDataObj[i]}" data-id="${i}">${AllDroupDataObj[i]}</li>`;
                    }
                }
                dom.html(menuHtml);
                if (dom.children("li").length > 0 && val != "") {
                    dom.children("li").eq(0).addClass("active");//第一个符合的高亮
                }
            }
            function getKeyUpChannel(dom, val) {
                let menuHtml = '', AllDroupDataObj = {};
                if (Array.isArray(AllDroupData)) {
                    AllDroupData.map(function (item, index) {
                        AllDroupDataObj[item[idKey]] = item[nameKey];
                    });
                } else {
                    AllDroupDataObj = AllDroupData;
                }
                for (let i in AllDroupDataObj) {
                    if (AllDroupDataObj[i].indexOf(val) != -1) {
                        menuHtml += `<li title="${AllDroupDataObj[i]}" data-value="${AllDroupDataObj[i]}" data-id="${i}">${AllDroupDataObj[i]}</li>`;
                    }
                }
                dom.html(menuHtml);
                if (dom.children("li").length > 0 && val != "") {
                    dom.children("li").eq(0).addClass("active");//第一个符合的高亮
                }
            }
        },
        // 展开收起
        SlideUpDownOuter: function () {
            // 展开收起功能
            $(".content_inner .title").unbind("click").on("click", function () {
                SlideUpDown($(this).children("i"));
            });
            function SlideUpDown(that) {
                if (that.hasClass("slideDown")) {
                    that.removeClass("slideDown");
                    that.parents(".content_inner").find(".table_outer").slideDown(618);
                } else {
                    that.addClass("slideDown");
                    that.parents(".content_inner").find(".table_outer").slideUp(618);
                }
            };
        },
        CopyVal: function (val) {
            // $(window).copy(val);
            const input = document.createElement('input');
                document.body.appendChild(input);
                input.value = val;  // 复制到剪切板的内容
                input.select();
                if (document.execCommand) {
                    document.execCommand('copy');
                    document.body.removeChild(input);
                } else {
                    console.error('当前浏览器不支持copy');
                    document.body.removeChild(input);
                }
        },
        getGuid() {
            return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
                return v.toString(16);
            });
        },
        ExportFile: function (opts) {
            var params = {
                type: 'POST',//默认POST
                url: '',//url
                async: true,//默认异步，同步false
                para: null,
                exportId: null,//下载的id
                exportItem: null,//下载的对象
                failedFn: null,//下载链接中止操作
                successFn: null,//下载成功后操作
                thenFn: null//下载报错返回json信息处理
            }
            params = $.extend(params, opts);
            let xhr = new XMLHttpRequest();
            xhr.responseType = 'blob';
            xhr.open(params.type, params.url, params.async);
            xhr.onreadystatechange = function () {
                console.log("readyState:", xhr.readyState, "status:", xhr.status);
                if (xhr.readyState == 4 && xhr.status == 200) {
                    // xhr.response;
                }
                if (xhr.readyState == 4 && xhr.status == 0) {
                    console.log("failed:", params.exportItem);
                    // 链接可能failed
                    params.failedFn ? params.failedFn(params.exportItem) : null;
                }
            };
            xhr.send(params.para);
            xhr.onload = function () {
                if (xhr.getResponseHeader("Content-type") == 'application/octet-stream') {
                    let name = '';
                    if (xhr.getResponseHeader("Content-Disposition").indexOf("=") > -1) {
                        name = decodeURIComponent(xhr.getResponseHeader("Content-Disposition").slice(xhr.getResponseHeader("Content-Disposition").indexOf("=") + 1));
                    }
                    let url = window.URL.createObjectURL(xhr.response);
                    let a = document.createElement("a");
                    a.href = url;
                    a.style.display = 'none';
                    a.download = name;
                    a.click();
                    window.URL.revokeObjectURL(url);
                    a.remove();
                    console.log(`load success:${params.exportId}`);
                    params.successFn ? params.successFn() : null;
                } else {
                    let reader = new FileReader;
                    reader.addEventListener('loadend', function (e) {
                        let data = JSON.parse(e.target.result);
                        console.log(`loadend:${params.exportId}`, data.returnMsg || null, data);
                        params.thenFn ? params.thenFn(data) : null;
                    });
                    reader.readAsText(xhr.response);
                }
            }
        },
        // 下载文件
        Download: function (options) {
            var params = {
                mime: "",
                base64: "",// base64
                fileName: "",// 文件名称
                url: ""// 下载地址
            }
            params = $.extend(params, options);
            // base64转流下载
            if (!params.url) {
                // var data = params.mime + params.base64;
                var len = params.base64.length;
                var bstr = atob(params.base64.split(",").length > 1 ? params.base64.split(",")[1] : params.base64);
                var u8arr = new Uint8Array(bstr.length);
                var n = u8arr.length;
                while (n--) {
                    u8arr[n] = bstr.charCodeAt(n);
                }
                var blob = new Blob([u8arr]);
                if (typeof (window.navigator.msSaveBlob) != 'undefined') {
                    window.navigator.msSaveBlob(blob, params.fileName);
                } else {
                    var url = window.URL.createObjectURL(blob);
                    var a = document.createElement("a");
                    a.href = url;
                    a.download = params.fileName;
                    a.click();
                    window.URL.revokeObjectURL(url);
                    // document.body.removeChild(a);
                }
                return;
            }
            // 文件下载地址下载
            if (!!params.url) {
                var a = document.createElement("a");
                a.href = params.url;
                a.download = params.fileName;
                a.target = "_blank";//新窗口打开
                a.click();
            }
        },
        //上传文件
        UpLoadFiles(options) {
            var params = {
                LastFileHideLoading: true,//上传完最后一个隐藏loading
                Multiple: false,// bool 是否多选 默认单选
                UpLoadFn: function () { }// function 文件处理
            }
            params = $.extend(params, options);
            var a = document.createElement("input");
            a.type = "file";
            if (params.Multiple) {
                a.multiple = true;
            }
            a.addEventListener('change', function () {
                $("#loadModel").modal("show")
                let allfileLength = this.files.length;
                if (allfileLength > 0) {
                    let filesArr = this.files;
                    Object.keys(filesArr).forEach(function (i) {
                        if (isNaN(i)) {//length
                            return
                        }
                        if (Number(i) === allfileLength - 1) {
                            getBase(filesArr[i], true);//最后一个结束loading
                        } else {
                            getBase(filesArr[i], false);
                        }
                    })
                    function getBase(file, isLast) {
                        var reader = new FileReader();
                        reader.onloadend = function () {
                            file.base64Content = reader.result;
                            // params.fileName = file.name;//	文件名称	String	Xxxx.xlsx
                            setTimeout(function () {
                                params.UpLoadFn ? params.UpLoadFn(file) : Util.BootstrapDialogAlert("缺少上传逻辑");
                                if (!!isLast && params.LastFileHideLoading) {
                                    $("#loadModel").modal("hide");
                                }
                            }, 500);
                        };
                        reader.readAsDataURL(file);
                    }
                }
            });
            a.click();
        },
        // 打开系统表单 : 实体名，id，参数，是否url打开（_blank）
        // tp:  Util.openEntityFormNewTab("new_accountquery",{id:id,extraqs:encodeURIComponent(`htf_account=${htfGroupId}&htf_accountname=${htfGroupName}&htf_accounttype=htf_account`)},true);
        openEntityFormNewTab(EntityName, Opts, UrlOpen) {
            UrlOpen = UrlOpen === false || UrlOpen === 'false' ? false : true;
            let defaultOpt = {
                id: '',
                navbar: 'on'
                // extraqs:'',
            }
            let defaultOpts = $.extend(defaultOpt, Opts);
            // 根据当前页面的hash，判定表单关闭的路径，url打开的表单也会带上当前页面的hash
            let herfCur = window.top.location.href;
            window.sessionStorage.setItem(herfCur.split("#")[1], herfCur);
            // 组装参数
            let params = '';
            for (let i in defaultOpts) {
                if (i === 'extraqs' && typeof (defaultOpts[i]) === 'object') {
                    let v = [];
                    for (let j in defaultOpts[i]) {
                        v.push(`${j}=${defaultOpts[i][j]}`);
                    }
                    let fv = encodeURIComponent(v.join('&'));//转译查找类型的参数
                    params += `&${i}=${fv}`;
                } else {
                    params += `&${i}=${defaultOpts[i]}`;
                }
            }
            // 默认新tab打开
            if (UrlOpen) {
                UrlETC = Util.GetETC(EntityName);
                setTimeout(function () {
                    var url = `/main.aspx?etc=${UrlETC}&pagetype=entityrecord${params}`;
                    window.open(url, "_blank");
                }, 318);
            } else {
                var url = `/main.aspx?etn=${EntityName}&pagetype=entityrecord${params}`;
                window.open(url);
            }
        },
        // 获取ETC
        GetETC: function (entity) {
            var cacheValue = window.sessionStorage.getItem(entity + 'ETC');
            if (!cacheValue) {
                var sObj = Util.SQuery('sp_getetc', 'entityname=' + entity);
                if (sObj.code == 1) {
                    if (sObj.data.Table.length > 0) {
                        cacheValue = sObj.data.Table[0]['objecttypecode'];
                        window.sessionStorage.setItem(entity + 'ETC', cacheValue);
                    }
                }
            }
            return cacheValue;
        },
        SQuery: function (sp, query) {
            var url = '/isv/getdata.aspx?sp=' + sp + '&' + query;
            var d = Util.Ajax(url);
            if (d.status == "200") {
                return JSON.parse(d.response);
            }
            return { code: 0, error: d.response };
        },
        Ajax: function (url, callback, method, postParams) {
            var oh = !!XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
            var m = typeof method == 'undefined' ? 'GET' : method.toUpperCase();
            try {
                if (!!callback) {
                    oh.onreadystatechange = function () {
                        if (oh.readyState == 4) {
                            if (oh.status == 200) {
                                callback(oh.responseText);
                            } else {
                                console.log('Util.Ajax status:', oh.status);
                            }
                        }
                    }
                }
                oh.open(m, url, !!callback);
                oh.send(!!postParams ? postParams : null);
                return oh;
            } catch (e) {
                console.log('Util.ajax error:' + e.message);
            }
        },
        // 获取用户id 从系统获取，或者从链接中获取userid
        getUserId: function (defaultUserId) {
            if (window.top.Xrm && !!window.top.Xrm.Page.context.getUserId()) {
                return window.top.Xrm.Page.context.getUserId().replace(/\{|\}/g, "").toUpperCase();
            }
            if (!!Util.getURLParams("userid")) {
                return Util.getURLParams("userid");
            }
            return defaultUserId || "";
        },
        // 获取用户姓名 从系统获取，或者从链接中获取username
        getUserName: function (defaultUserName) {
            if (window.top.Xrm) {
                return decodeURIComponent(window.top.Xrm.Page.context.getUserName());
            }
            if (!!Util.getURLParams("username")) {
                return decodeURIComponent(Util.getURLParams("username"));
            }
            return defaultUserName || "";
        },
        /**
         * checkUserRoles 检测是否包含某些角色
         * targetRoles 期望匹配的角色
         * userRoleZY：sessionStorage
         */
        checkUserRoles: function (targetRoles) {
            // let roles = Object.values(JSON.parse(window.localStorage.getItem('cacheHH')).role);
            let userid = Util.getUserId();
            let rolesCache = window.sessionStorage.getItem('userRoleZY') ?
                (JSON.parse(window.sessionStorage.getItem('userRoleZY'))[userid] || [])
                : [],
                t;//是否满足匹配
            // 有缓存从缓存里找，没有从接口获取
            if (rolesCache.length > 0) {
                if (Util.UnionArray(rolesCache, targetRoles).length > 0) {
                    t = true;
                } else {
                    t = false;
                }
                return t;
            }
            // 没有从接口获取角色
            let roles = [];
            Util.iAjaxNoLoading("I_comm_getroles", {}, function (data) {
                let outPut = JSON.parse(data.OutMsg);
                if (!outPut.error) {
                    roles = outPut.data;
                    let sessionJson = {};
                    sessionJson[userid] = roles;
                    window.sessionStorage.setItem("userRoleZY", JSON.stringify(sessionJson));
                    if (Util.UnionArray(roles, targetRoles).length > 0) {
                        t = true;
                    } else {
                        t = false;
                    }
                } else {
                    Util.BootstrapDialogAlert("获取角色失败（胡老师）：" + outPut.error);
                }
            }, null, null, false);
            console.log("checkUserRoles检测是否包含某些角色:", JSON.parse(window.sessionStorage.getItem('userRoleZY'))[userid], targetRoles, t);
            return t;
        },
        // 获取当前登录人角色,
        // islike模糊匹配
        UserHasAnyRole: function (names, islike) {
            console.log(names, islike);
            if (Array.isArray(names)) {
                for (var i = 0; i < names.length; i++) {
                    var roles = Util.GetUserRoleNames();
                    for (var j = 0; j < roles.length; j++) {
                        if (roles[j] == names[i] || (!!islike && roles[j].indexOf(names[i]) > -1)) {
                            return true;
                        }
                    }
                }
            }
            else {
                var ns = [];
                if (names.indexOf(',') > 0) {
                    ns = names.split(',');
                } else if (names.indexOf(';') > 0) {
                    ns = names.split(';');
                } else {
                    ns.push(names);
                }
                return Util.UserHasAnyRole(ns, islike);
            }
            return false;
        },
        // 获取当前登录人角色
        GetUserRoleNames : function(){
            let userid = Util.getUserId();
            let rolesCache = window.sessionStorage.getItem('userRoleZY') ?
                (JSON.parse(window.sessionStorage.getItem('userRoleZY'))[userid] || [])
                : [];
            if( rolesCache.length > 0 ){
                return rolesCache
            }
            Util.iAjaxNoLoading("I_comm_getroles", {}, function (data) {
                let outPut = JSON.parse(data.OutMsg);
                if (!outPut.error) {
                    roles = outPut.data;
                    let sessionJson = {};
                    sessionJson[userid] = roles;
                    window.sessionStorage.setItem("userRoleZY", JSON.stringify(sessionJson));
                } else {
                    Util.BootstrapDialogAlert("获取角色失败（胡老师）：" + outPut.error);
                }
            }, null, null, false);
            return roles
        },
        // 罗马数组转化
        ConvertRome: function (num) {
            var ans = "";
            var k = Math.floor(num / 1000);
            var h = Math.floor((num % 1000) / 100);
            var t = Math.floor((num % 100) / 10);
            var o = num % 10;
            var one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
            var ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'];
            var hundred = ['C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
            var thousand = 'M';
            for (var i = 0; i < k; i++) {
                ans += thousand;
            }
            if (h)
                ans += hundred[h - 1];
            if (t)
                ans += ten[t - 1];
            if (o)
                ans += one[o - 1];
            return ans;
        },
        // 清空选择数组，重新初始化后台分页选择数据--- 防止数据重定向
        InitBSServerSelected(tableId, idKey, targetArr, selectedFn, btnShowHideFn) {
            targetArr = [];
            Util.BSServerSelected(tableId, idKey, targetArr, selectedFn, btnShowHideFn);
        },
        /**
         * 解决后台分页无法保存分页选中问题
         * @param {tableid} tableId 
         * @param {唯一键} idKey 
         * @param {选中存放的数组} targetArr 
         * @param {操作后方法} selectedFn 
         * @param {操作后按钮的逻辑方法：showFn显示方法；hideFn：隐藏方法} btnShowHideFn 
         */
        BSServerSelected(tableId, idKey, targetArr, selectedFn, btnShowHideFn) {
            var $table = $(`#${tableId}`)
            //选中事件操作数组
            let union = function (array, ids) {
                ids.map(function (item, i) {
                    if (!Util.HasCurrent(array, item[idKey], idKey)) {
                        array.push(item);
                    }
                });
                // 选中操作显示按钮
                btnShowHideFn && btnShowHideFn.showFn ? btnShowHideFn.showFn(array) : null;
                return array;
            };
            //取消选中事件操作数组
            let difference = function (array, ids) {
                ids.map(function (item, i) {
                    let idx = Util.HasCurrentIdx(array, item[idKey], idKey);
                    if (!!idx || idx == 0) {
                        array.splice(idx, 1);
                    }
                });
                // 取消后选中数据为空 隐藏按钮
                btnShowHideFn && btnShowHideFn.hideFn ? btnShowHideFn.hideFn(array) : null;
                return array;
            };
            let _ = { "union": union, "difference": difference };
            //绑定选中事件、取消事件、全部选中、全部取消
            $table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
                // 当前页取消全选
                if ($.isArray(rows) && rows.length === 0) {
                    rows = $table.bootstrapTable("getData");
                }
                // 某条记录
                let selected = !$.isArray(rows) ? [rows] : rows;
                func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
                targetArr = _[func](targetArr, selected);
                // 选择事件触发后事件（例如渲染已选列表）
                !!selectedFn ? selectedFn(targetArr, func) : null;

                // 如果有冻结列，则需要触发冻结列
                if ($(`#${tableId}`).parents(`.fixed-table-body`).next().hasClass("fixed-table-body-columns")) {
                    if (e.type === 'check') {
                        // 冻结列选中记录，不会触发全选状态，需要js触发
                        if (targetArr.length === $(`#${tableId}`).bootstrapTable("getOptions").totalRows) {
                            $(`.fixed-table-body-columns #${tableId} input[name=btSelectAll]`)[0].checked = true;
                        }
                        // 冻结列添加选中状态
                        $(".fixed-table-body-columns tbody tr input:checked").parents("tr").addClass("selected");
                    } else if (e.type === 'uncheck') {
                        // 冻结列取消选中，不会触发全选状态的取消，需要js触发
                        $(`#${tableId} input[name=btSelectAll]`).attr("checked", false);
                        // 冻结列取消选中状态
                        $(".fixed-table-body-columns tbody tr input:not(:checked)").parents("tr").removeClass("selected");
                    } else if (e.type === 'check-all') {
                        // 冻结列添加选中状态 未选中的选中
                        $(".fixed-table-body-columns tbody tr").addClass("selected").find("input:not(:checked)").click();
                    } else if (e.type === 'uncheck-all') {
                        // 冻结列移除选中状态 以选中的取消
                        $(".fixed-table-body-columns tbody tr").removeClass("selected").find("input:checked").click();
                    }
                }
            });
        },
        // 分页后反项选择某行数据
        BSSelectedInvert(tableId, idKey, targetArr) {
            let pageData = $(`#${tableId}`).bootstrapTable("getData");
            pageData.map(function (item, index) {
                if (Util.HasCurrent(targetArr, item[idKey], idKey)) {
                    $(`#${tableId}`).find("tbody tr").eq(index).find(".bs-checkbox input").click();
                    // 有冻结列 反选冻结列
                    if ($(`#${tableId}`).parents(`.fixed-table-body`).next().hasClass("fixed-table-body-columns")) {
                        $(`.fixed-table-body-columns`).find("tbody tr").eq(index).find(".bs-checkbox input").click();
                    }
                }
            });
        },
        // 判断是否含有指定id数据
        HasCurrent(array, id, idKey) {
            let t = false;
            array.map(function (item, i) {
                if (item[idKey] === id) {
                    t = true;
                }
            });
            return t;
        },
        // 获取指定id数据下标
        HasCurrentIdx(array, id, idKey) {
            let t;
            array.map(function (item, i) {
                if (item[idKey] === id) {
                    t = i;
                }
            });
            return t;
        },
        // 显示listloading
        ShowLoadingBox(ParentDom) {
            ParentDom = ParentDom || ".content";
            $(`${ParentDom} .table_loading`).show();
            $(`${ParentDom} .noData_box`).hide();
            $(`${ParentDom} .list_table`).hide();
        },
        // 显示暂无数据
        ShowNoDataBox(ParentDom) {
            ParentDom = ParentDom || ".content";
            $(`${ParentDom} .table_loading`).hide();
            $(`${ParentDom} .noData_box`).show();
            $(`${ParentDom} .list_table`).hide();
        },
        // 显示列数据
        ShowListBox(ParentDom) {
            ParentDom = ParentDom || ".content";
            $(`${ParentDom} .table_loading`).hide();
            $(`${ParentDom} .noData_box`).hide();
            $(`${ParentDom} .list_table`).show();
        },
        // 返回顶部按钮自定义
        ReturnTop(num) {
            num = num || 300;
            $("body").append(`<div id="return_top" style="display: none;">
                <div class="box-in"></div>
            </div>`);
            $(document).ready(function () {
                $(window).scroll(function () {
                    if ($(window).scrollTop() > num) {
                        $("#return_top").fadeIn(500);
                    } else {
                        $("#return_top").fadeOut(500);
                    }
                });
                // 当点击返回按钮后，回到页面顶部位置
                $("#return_top").click(function () {
                    $('body,html').animate({
                        scrollTop: 0
                    }, 318);
                    return false;
                });
            });
        },
        // 自定义底部滚动条
        BottomTableScroll(tableId) {
            // 再次初始化时清空
            if ($(".bottom_table_scroll").length > 0) {
                $(".bottom_table_scroll").remove();
            }
            // 表格所在div
            let $TableOuter = $(`#${tableId}`).parents(".table_outer");
            // 表格父元素（滚动元素）
            let $FixedBody = $(`#${tableId}`).parent();
            // 表格滚动条超出页面时 才添加自定义滚动条
            if ($TableOuter.height() + $TableOuter.offset().top < $(window).height()) {
                return;
            }
            // 添加自定义滚动代码
            $("body").append(`<div class="bottom_table_scroll" style="width:${$FixedBody.width()}px;margin-left:-${$FixedBody.width() * 0.5}px;"><p class="table_width" style="width:${$(`#${tableId}`).width()}px"></p></div>`);
            // 初始化时可能有滚动
            $(".bottom_table_scroll").scrollLeft($FixedBody.scrollLeft());

            // 自定义滚动条滚动时，触发表格的滚动
            $(".bottom_table_scroll").on("scroll", function () {
                $FixedBody.scrollLeft($(this).scrollLeft());
            });
            // 屏幕滚动条滚动，控制自定义滚动条的显示
            $(window).on("scroll", function () {
                // 横向滚动条溢出，显示自定义滚动条
                if ($FixedBody.height() + $FixedBody.offset().top > ($(window).height() + $(window).scrollTop())) {
                    $(".bottom_table_scroll").show();
                } else {
                    $(".bottom_table_scroll").hide();
                }
            })
            // 初始化显示隐藏
            if ($FixedBody.height() + $FixedBody.offset().top > ($(window).height() + $(window).scrollTop())) {
                $(".bottom_table_scroll").show();
            } else {
                $(".bottom_table_scroll").hide();
            }
        },
        // 刷新上个页面
        RefreshLastPage(LastPageRefreshFn,option) {
            var _refreshToggle = true;
            if (!!LastPageRefreshFn && window.opener && $.isFunction(window.opener[LastPageRefreshFn]) && _refreshToggle) {
                _refreshToggle = false;
                window.opener[LastPageRefreshFn](option);//刷新上个页面（项目管理）
            }
        },
        // 获取用户推送信息
        GetSystemUserInfo(USERID) {
            // New_DepartmentId:"2747a39c-bf55-4d1a-a22d-07d54bc1a777"
            // New_DepartmentIdName:"上海业务中心"
            // New_FullName:"李慧杰"
            // New_InformationPushId:"d57ee103-16ba-4d51-b720-469671da6b2a"
            // New_UserNo:"177"
            let SystemUserInfoCache = window.sessionStorage.getItem('SystemUserInfoZY') ? (JSON.parse(window.sessionStorage.getItem('SystemUserInfoZY'))[USERID] || {}) : {};
            if (!SystemUserInfoCache.New_DepartmentIdName) {
                Util.iAjax("I_report_GetInformationPushBy", { SystemUserId: USERID }, function (res) {
                    let data = JSON.parse(res.OutMsg).data;
                    window.sessionStorage.setItem('SystemUserInfoZY', JSON.stringify(data));
                    SystemUserInfoCache = data;
                }, null, null, false);
            }
            return SystemUserInfoCache;
        },
        // 切换按钮
        PeriodChange: function () {
            //切换active li
            $(".period").on("click", "li", function () {
                $(this).unbind("click");
                if ($(this).siblings().length == 0) {
                    // 单个li 
                    if ($(this).hasClass("active")) {
                        $(this).removeClass("active");
                    } else {
                        $(this).addClass("active");
                    }
                } else {
                    // 多个li
                    $(this).addClass("active").siblings().removeClass("active");
                }
            })
        },
        //获取某月的月初和月末
        getNowDayofMonth: function (date) {
            var nowDate = !!date ? new Date(date) : new Date();
            var cloneDate = !!date ? new Date(date) : new Date();
            var fullYear = nowDate.getFullYear()
            var month = nowDate.getMonth() + 1
            var endOfMonth = new Date(fullYear, month, 0).getDate() //获取本月最后一天
            function getFullDate(target) {
                var D, y, m, d
                if (target) {
                    D = new Date(target)
                    y = D.getFullYear()
                    m = D.getMonth() + 1
                    d = D.getDate()
                } else {
                    y = fullYear
                    m = month
                    d = date
                }

                m = m > 9 ? m : '0' + m
                d = d > 9 ? d : '0' + d
                return y + '-' + m + '-' + d
            }
            var arr = []
            arr[0] = getFullDate(cloneDate.setDate(1)) //第一天
            arr[1] = getFullDate(cloneDate.setDate(endOfMonth)) //最后一天
            return arr
        },
        // 判断日期是周几
        getWeek: function (myDate) {
            var myDate = myDate ? new Date(myDate) : new Date();
            // var year = myDate.getFullYear(); //年
            // var month = myDate.getMonth() + 1; //月
            // var day = myDate.getDate(); //日
            var days = myDate.getDay();
            switch (days) {
                case 1:
                    days = '星期一';
                    break;
                case 2:
                    days = '星期二';
                    break;
                case 3:
                    days = '星期三';
                    break;
                case 4:
                    days = '星期四';
                    break;
                case 5:
                    days = '星期五';
                    break;
                case 6:
                    days = '星期六';
                    break;
                case 0:
                    days = '星期日';
                    break;
            }
            // var str = year + "年" + month + "月" + day + "日  " + days;
            var str = days;
            return str;
        },
        // 获取所在季度
        getQuarter: function (time) {
            time = time ? new Date(time) : new Date();
            let M = time.getMonth() + 1;
            let Q = 0;
            if (M >= 1 && M <= 3) {
                Q = 1
            } else if (M >= 4 && M <= 6) {
                Q = 2
            } else if (M >= 7 && M <= 9) {
                Q = 3
            } else if (M >= 10 && M <= 12) {
                Q = 4
            }
            return Q
        },
        // 获取下个月
        getNextMonth: function (date) {
            var nowDate = !!date ? new Date(date) : new Date();
            var fullYear = nowDate.getFullYear();
            var month = nowDate.getMonth() + 2;
            if (month < 10) {
                month = '0' + month
            }
            return fullYear + "-" + month;
        },
        // 防抖 --多次点击点击事件只会触发一次
        Debounce(fn, timeout) {
            timeout = timeout || 500
            let timer = null
            return function () {
                if (timer) {
                    clearTimeout(timer)
                }
                timer = setTimeout(fn, timeout)
            }
        },
        // 节流 --在执行一个次函数后 短时间不在触发
        Throttle(fn, timeout) {
            timeout = timeout || 500
            let flag = true
            return function () {
                if (!flag) {
                    // 已经触发 所以让函数休息
                    return false
                }
                flag = false
                setTimeout(() => {
                    fn()
                    flag = true
                }, timeout);


            }
        },
        // 计算日期大小
        CalTime: function (date1, date2) {
            var oDate1 = new Date(date1);
            var oDate2 = new Date(date2);

            return oDate1.getTime() - oDate2.getTime();
        },
        // select 填充下拉选项，赋默认值
        setValue_SelectDom(dataArr, target) {
            //设置默认值，或者获取数组第一个值
            target = target || dataArr[0].value;
            let htmlOption = '';
            dataArr.forEach(item => {
                htmlOption += `<option value="${item.value}" ${item.value === target ? 'selected' : ''}>${item.name}</option>`;
            });
            return htmlOption;
        }
    }
}
UtilFn();
// 切换选择项
Util.PeriodChange();
/**
 * 自定义编辑方法
 */
function EditUtilFn() {
    return EditUtil = {
        /**
         * 更换为可编辑状态
         * @param {父元素} ParentDom "#xxx" ".xxx"
         * @param {编辑后触发} editFn 
         * @param {编辑前触发} beforeFn 
         * @param {时间init以及切换方法} dateOptions {dateOpt:..,dateChangeFn:...}
         * @param {是否隐藏分页切换} hidePagination 默认false不隐藏
         */
        EditDom(getOpts) {
            let defOpt = {
                ParentDom: 'body',//父元素
                editFn: null, //编辑状态后fn
                beforeFn: null,//编辑状态切换前fn
                dateOptions: {
                    dateOpt: {//下拉时间选择默认参数
                        language: 'zh-CN',
                        format: "yyyy-mm-dd",
                        autoClose: 1,
                        startView: 2,
                        minView: "month",
                        autoclose: true,
                        clearBtn: true
                    },
                    dateChangeFn: null//时间切换触发事件
                },
                hidePagination: false
            };
            let opts = $.extend(true, defOpt, getOpts);
            // 编辑状态切换前fn
            opts.beforeFn ? opts.beforeFn() : null;
            // 父元素
            let ParentDom = typeof (opts.ParentDom) === 'string' ? $(opts.ParentDom) : opts.ParentDom;
            // 文本框
            ParentDom.find(`.edit_text`).each((i, item) => {
                if ($(item).find(".editing_input").length == 0) {
                    let curHtml = $(item).find("p.ellipsis_p").html(),
                        curId = !!$(item).find("p.ellipsis_p").attr("data-id") ? $(item).find("p.ellipsis_p").attr("data-id") : '';
                    curHtml = (curHtml === '--' || curHtml === ' ') ? '' : curHtml;
                    $(item).find("p.ellipsis_p").hide().after(`<input type="text" class="editing_input" ${$(item).hasClass("readonly") ? 'readonly' : ''} title="${curHtml}" data-selectid='${curId}' value='${curHtml}'>`);
                } else {
                    // 初始化弹窗已定义了input,不用点击编辑生成input
                    let curId = !!$(item).find("p.ellipsis_p").attr("data-id") ? $(item).find("p.ellipsis_p").attr("data-id") : '';
                    if (!!curId) {
                        let curHtml = $(item).find("p.ellipsis_p").html();
                        curHtml = curHtml == '--' ? '' : curHtml;
                        $(item).find("p.ellipsis_p").hide().next().val(curHtml).attr({ "title": curHtml, "data-selectid": curId }).show();
                    } else {
                        $(item).find("p.ellipsis_p").hide().next().show();
                    }
                }
            });
            // 多行文本框
            ParentDom.find(`.edit_textarea`).each((i, item) => {
                // 控制高度
                if (item.nodeName === "TD") {
                    $(item).css("height", $(item).parents("tr").css("height"));
                }
                // 渲染操作
                if ($(item).find(".editing_textarea").length == 0) {
                    let curHtml = $(item).find("p.ellipsis_p").html();
                    curHtml = curHtml == '--' ? '' : curHtml;
                    $(item).find("p.ellipsis_p").hide().after(`<textarea type="text" class="editing_textarea" title="${curHtml}">${curHtml}</textarea>`);
                } else {
                    $(item).find("p.ellipsis_p").hide().next().show();
                }
            });
            // 时间选择
            ParentDom.find(`.edit_date`).each((i, item) => {
                if ($(item).find(".editing_date").length == 0) {
                    let curHtml = $(item).find("p.ellipsis_p").html();
                    curHtml = curHtml == '--' ? '' : curHtml;
                    $(item).find("p.ellipsis_p").hide().after(`<div class="editing_date"><input type="text" disabled readonly title="${curHtml}" value='${curHtml}'><i class="icon iconrili1"></i></div>`);
                    if ($(item).hasClass("disabled")) {
                        $(item).find(`.editing_date`).addClass("disabled");
                    } else {
                        // 时间选择init
                        $(item).find(`.editing_date input`).datetimepicker(opts.dateOptions.dateOpt).on('changeDate', function (e) {
                            opts.dateOptions.dateChangeFn ? opts.dateOptions.dateChangeFn($(item).find(`.editing_date input`)) : null;
                        });
                        $(item).find(`.editing_date input`).attr("disabled", false);
                    }
                } else {
                    $(item).find("p.ellipsis_p").hide().next().show();
                }
            });
            // 下拉框
            ParentDom.find(`.edit_droup`).each((i, item) => {
                if ($(item).find(".editing_droup").length == 0) {
                    let droup_value = [], droup_value_html = '', droup_value2 = [];//下拉数组1、2 ；下拉html
                    // 下拉数组
                    let droupV = $(item).find("p.ellipsis_p").attr("data-droupvalue");
                    if (!!droupV) {
                        droup_value = eval('(' + droupV + ')');
                    }
                    //可能有两个下拉数组 tp：个性化服务明细中行编辑标签，标签
                    let droupV2 = $(item).find("p.ellipsis_p").attr("data-droupvalue2");
                    if (!!droupV2) {
                        droup_value2 = eval('(' + droupV2 + ')');
                    }
                    if (!!droup_value && droup_value.length > 0) {
                        droup_value.forEach((item, idx) => {
                            droup_value_html += `<li class="${!!droupV2 ? 'select_2_list1' : ''}" title="${item.value}" data-value="${item.value}" data-id="${item.id}">${item.value}</li>`;
                        });
                    }
                    if (!!droup_value2 && droup_value2.length > 0) {
                        droup_value_html += `<li class="drop_menu2_line"></li>`;
                        droup_value2.forEach((item, idx) => {
                            droup_value_html += `<li class="${!!droupV2 ? 'select_2_list2' : ''}" title="${item.value}" data-value="${item.value}" data-id="${item.id}">${item.value}</li>`;
                        });
                    }
                    let curHtml = $(item).find("p.ellipsis_p").html();
                    curHtml = curHtml == '--' ? '' : curHtml;
                    $(item).find("p.ellipsis_p").hide().after(`
                        <div class="dropdown_box ${ !!droupV2 ? 'dropdown_box_select2' : ''} ${$(item).hasClass("readonly") ? 'readonly' : ''} editing_droup">
                            <div class="dropdown_input flexBetween">
                                <span class="dropdown_value" data-selectid="${$(item).find("p.ellipsis_p").attr("data-id")}">${curHtml}</span>
                                <i class="icon iconxiajiantou"></i>
                            </div>
                            <ul class="dropdown_menu" style="display:none">
                                ${droup_value_html}
                            </ul>
                    </div>`);
                } else {
                    $(item).find("p.ellipsis_p").hide().next().show();
                }
            });
            // 编辑状态后fn
            setTimeout(() => {
                opts.editFn ? opts.editFn() : null;
            }, 500);
            // 是否隐藏分页切换
            if (opts.hidePagination || opts.hidePagination === 'true') {
                // 防止数据翻页丢失隐藏翻页
                if (ParentDom.parents(".table_box").length > 0) {
                    ParentDom.parents(".table_box").find(".fixed-table-pagination").addClass("hidePagination").hide();
                } else {
                    ParentDom.find(".fixed-table-pagination").addClass("hidePagination").hide();
                }
            }
        },
        /**
         * 更换为不可编辑状态 保存方法
         * @param {父元素} ParentDom 
         * @param {保存后触发} saveFn 
         */
        SaveDom(getOpts) {
            let defOpt = {
                ParentDom: 'body',//父元素
                saveFn: null //保存状态后fn
            };
            let opts = $.extend({}, defOpt, getOpts);
            let ParentDom = $(opts.ParentDom);
            // 文本框
            ParentDom.find(`.editing_input`).each((i, item) => {
                let curHtml = $(item).val().trim();
                let preHtml = $(item).prev().html().trim();
                // 添加是否修改标识 edited
                if (preHtml !== curHtml) {
                    $(item).prev().addClass("edited");
                }
                if ($(item).prev().hasClass("readonly") && $(item).attr("data-selectid")) {
                    // 弹窗按钮 选择值
                    $(item).hide().prev().show().html(curHtml).attr({ "data-id": $(item).attr("data-selectid"), "title": curHtml });
                } else if ($(item).parents(".edit_text").hasClass("readonly") && $(item).attr("data-selectid")) {
                    // bootstraptable 表格内弹窗按钮 选择值
                    $(item).hide().prev().show().html(curHtml).attr({ "data-id": $(item).attr("data-selectid"), "title": curHtml });
                } else {
                    $(item).hide().prev().show().html(curHtml).attr({ "title": curHtml });
                }
            });
            // 多行文本框
            ParentDom.find(`.editing_textarea`).each((i, item) => {
                let curHtml = $(item).val().trim();
                let preHtml = $(item).prev().html().trim();
                // 添加是否修改标识 edited
                if (preHtml !== curHtml) {
                    $(item).prev().addClass("edited");
                }
                $(item).hide().prev().show().html(curHtml).attr({ "title": curHtml });
            });
            // 时间选择
            ParentDom.find(`.editing_date`).each((i, item) => {
                let curHtml = $(item).find("input").val().trim();
                let preHtml = $(item).prev().html().trim();
                // 添加是否修改标识 edited
                if (preHtml !== curHtml) {
                    $(item).prev().addClass("edited");
                }
                $(item).hide().prev().show().html(curHtml).attr({ "title": curHtml });
            });
            // 下拉框
            ParentDom.find(`.editing_droup`).each((i, item) => {
                let curHtml = $(item).find(".dropdown_value").html().trim();
                let preHtml = $(item).prev().html().trim();
                // 添加是否修改标识 edited
                if (preHtml !== curHtml) {
                    $(item).prev().addClass("edited");
                }
                $(item).hide().prev().show().html(curHtml).attr({ "data-id": $(item).find(".dropdown_value").attr("data-selectid"), "title": curHtml });
            });
            setTimeout(() => {
                opts.saveFn ? opts.saveFn() : null;
            }, 500);

            // 防止数据翻页丢失 保存后显示翻页
            // 有hidePagination类，表示编辑时隐藏了分页按钮
            if (ParentDom.parents(".table_box").length > 0 && ParentDom.parents(".table_box").find(".fixed-table-pagination").hasClass("hidePagination")) {
                ParentDom.parents(".table_box").find(".fixed-table-pagination").show();
            } else if (ParentDom.find(".fixed-table-pagination").hasClass("hidePagination")) {
                ParentDom.find(".fixed-table-pagination").show();
            }
        },
        // td添加Class 
        // 文本框
        FormatCellStyleText(value, row, index) {
            return {
                classes: `edit_text ${!!row.canEdit ? null : "disabled"}`
                // 'css':{}
            }
        },
        // 文本框 只读
        FormatCellStyleTextReadonly(value, row, index) {
            return {
                classes: 'edit_text readonly'
                // 'css':{}
            }
        },
        // 多行文本
        FormatCellStyleTextArea(value, row, index) {
            return {
                classes: `edit_textarea ${!!row.canEdit ? null : "disabled"}`
                // 'css':{}
            }
        },
        // 多行文本 只读
        FormatCellStyleTextAreaReadonly(value, row, index) {
            return {
                classes: 'edit_textarea readonly'
                // 'css':{}
            }
        },
        // 日期
        FormatCellStyleDate(value, row, index) {
            return {
                // 根据数据是否更改canEdit、以及是否可以更改日期dateCanEdit 判断添加是否可编辑
                classes: `edit_date ${row.dateCanEdit === false ? "disabled" : (!!row.canEdit || row.canEdit === undefined ? '' : 'disabled')}`
            }
        },
        // 日期 禁用
        FormatCellStyleDateDisabled(value, row, index) {
            return {
                classes: 'edit_date disabled'
            }
        },
        // 下拉
        FormatCellStyleDroup(value, row, index) {
            return {
                classes: `edit_droup ${!!row.canEdit || row.canEdit === undefined ? null : "disabled"}`
            }
        },
        // 隐藏
        FormatCellStyleNone(value, row, index) {
            return {
                classes: 'none'
            }
        },
        //下拉选项处理 获取编辑列下拉选项
        // tp:举个栗子 参考重点账户业绩检视
        GetDroupValue(getOpts) {
            let defOpt = {
                attrName: '',//选项集名称
                droupClass: '',//下拉选项类名
                enTityName: 'htf_contact',//实体名
                formatFn: null,//数据处理方法，例如 按照属性值排序
                operateFn: null,//操作方法
                filterArr: []//过滤选项集合
            };
            let opts = $.extend({}, defOpt, getOpts);
            Util.iAjaxNoLoading('I_Inter_GetInterPicklistList', { filter: { entity: opts.enTityName, attributename: opts.attrName } },
                function (res) {
                    let outPut = JSON.parse(res.OutMsg).data.Rows;
                    let droupArr = [];
                    outPut.map((item, idx) => {
                        if (opts.filterArr.length > 0) {
                            if (opts.filterArr.indexOf(item.value) != -1) {
                                let obj = {};
                                obj.id = item.attributevalue;
                                obj.value = item.value;
                                obj.displayorder = item.displayorder;
                                droupArr.push(obj);
                            }
                        } else {
                            let obj = {};
                            obj.id = item.attributevalue;
                            obj.value = item.value;
                            obj.displayorder = item.displayorder;//排序字段
                            droupArr.push(obj);
                        }
                    });
                    // 如果排序字段有值，则排序
                    if (droupArr.length > 0 && !!droupArr[0].displayorder) {
                        droupArr = droupArr.sort(function (a, b) { return Number(a.displayorder) - Number(b.displayorder); });
                    }
                    console.log(opts.attrName + ":", droupArr);

                    !!opts.formatFn ? droupArr = opts.formatFn(droupArr) : null;
                    !!opts.droupClass ? $(`.form_msg .ellipsis_p.${opts.droupClass}`).attr("data-droupvalue", JSON.stringify(droupArr)) : null;
                    !!opts.operateFn ? opts.operateFn(droupArr) : null;
                }
            );
        },
        // 调整固定列行高
        FixedColumnsTrHeight(tableId, UniqueId, heightTrInit) {//MsgTable
            let heightTr = heightTrInit || '30px';
            let fixedHeight = $(`#${tableId}`).css("height");
            $(`#${tableId}`).parents(".bootstrap-table").find(".fixed-table-body-columns").css("height", fixedHeight);
            $(`#${tableId}`).parents(".bootstrap-table").find(".fixed-table-body-columns tbody tr").each(function () {
                let curId = $(this).attr("data-uniqueid");
                let $this = $(this);
                let $thisTrIdx = $(this).index();
                let curData = $(`#${tableId}`).bootstrapTable("getData").filter(function (item) { return item[UniqueId] == curId; });
                if (curData.length > 0) {//新增时特殊 null
                    $this.find("td").css({ "height": heightTr, "padding": "0px 10px" });
                }
                $this.css({ "height": $(`#${tableId} tbody tr`).eq($thisTrIdx).css("height") });
            });
            // 窗口缩放 重新计算
            $(window).on("resize", function () {
                EditUtil.FixedColumnsTrHeight(tableId, UniqueId, heightTrInit);
            });
        },
        // 校验数据 bootstrap-tooltip提示
        TestEditValue(testTips, $this) {
            //校验结果
            let t = true;
            // 校验返回false 或者 返回提示语则提示
            if (testTips !== true && !!testTips) {
                t = false;
                // 防止重复初始化tooltip
                if (!$this.attr("aria-describedby")) {
                    $this.attr({ "data-toggle": "tooltip", "data-trigger": "manual", "title": testTips });
                }
                $this.tooltip("show");
            }
            return t;
        },
        // 校验input输入 tp:htf_directSale_channelList新建直销渠道
        InputValTips(Content) {
            let beforeVal;
            $(Content).on("focus", "input", function (e) {
                let $this = $(this);
                beforeVal = $this.val();
                // 聚焦时销毁提示框
                // $this.tooltip("destroy");
            });
            $(Content).on("blur", "input", function (e) {
                let $this = $(this),
                    //校验方法
                    //EditUtil中没有对应方法时，可以在js中对EditUtil附加方法
                    testFn = $this.attr("data-testfn"),
                    testFnTips = $this.attr("data-testfntips");
                // 数据发生改变时  空数据也给校验提示
                if (beforeVal !== $this.val() || $.trim($this.val()) === "") {
                    // 校验方法中 校验不通过 显示tooltip
                    // 校验通过 隐藏tooltip
                    if (EditUtil.TestEditValue(EditUtil[testFn]($this.val(), testFnTips), $this)) {
                        if (!!$this.attr("aria-describedby")) {
                            $this.tooltip("hide");
                        }
                    };
                }
            });
        },
        /**
         * 正则校验
         * @param {*} val 校验值 
         * @param {*} returnTips :bool 是否返回提示文字。默认是:返回提示文字，否：返回bool
         */
        // 校验网址
        testURL(val, returnTips) {
            let regs = /^(((ht|f)tps>):\/\/)?[\w]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~#-])?$/;
            // 校验不通过提示文字
            if (!regs.test(val)) {
                return !!returnTips ? returnTips : false;
            }
            return true;
        },
        // 校验手机号
        testPhone(val, returnTips) {
            let regs = /^((?:(?:\+|00)86)\d{11}|1\d{10})$/;
            // 校验不通过提示文字
            if (!regs.test(val)) {
                return !!returnTips ? returnTips : false;
            }
            return true;
        },
        // 校验必填项空值
        testNull(val, returnTips) {
            val = val.replace(/\s*/g, "");
            // 校验不通过提示文字
            if (!val) {
                return !!returnTips ? returnTips : false;
            }
            return true;
        },
        /**
         * 表单必填校验
         * @param {*} mustObj 可以是数组['检验字段']如例1，这种不需要给提示；也可以是对象如例2，需要给出每个校验字段的提示语
         * @param {*} testObj 检验的对象，可能是数组也可能是对象 例如保存的对象，校验必填项是否填写完整
         * @param {*} targetKey 可能校验的是保存对象下的某个字段值 例如 [{...,Data:{}}]校验Data,如例1
         */
        // ep1:
        // testMustValue(["FollowContent"], [{filter:...},{filter:...}], "filter")
        // ep2:
        // let testMustV = {
        //     HtfContactName: "请输入机构联系人姓名！",
        //     hasAlert:true//是否需要提示
        // }
        // testMustValue(testMustV, SaveJson)
        testMustValue(mustObj, testObj, targetKey) {
            // 如果没有设置是否需要提示，则默认需要提示
            if( !mustObj.hasOwnProperty("hasAlert") ){
                mustObj.hasAlert = true;
            }
            //targetKey：可能校验的是testObj数组里的一个个对象，也可能是一个个对象下某个数组[{...,Data:{}}]
            let toggleMust = true;
            let toggleMustKey ;
            if (Array.isArray(mustObj) && Array.isArray(testObj)) {
                mustObj.forEach((item, Index) => {
                    testObj.forEach((itm, Idx) => {
                        //校验的对象的键
                        if (targetKey) {
                            // 没有保存该值或值为空，都认为未填写
                            if ( !itm[targetKey][item] || itm[targetKey][item] === '') {
                                toggleMustKey = item;// 未填写的键
                                toggleMust = false;
                                return;
                            }
                        } else {
                            // 没有保存该值或值为空，都认为未填写
                            if ( !itm[item] || itm[item] === '') {
                                toggleMustKey = item;// 未填写的键
                                toggleMust = false;
                                return;
                            }
                        }
                    })
                    if (!toggleMust) {
                        return;
                    }
                })
            } else {
                for (let i in mustObj) {
                    // 没有保存该值或值为空，都认为未填写
                    if ( ( !testObj[i] || testObj[i] === '') && i != 'hasAlert' ) {
                        toggleMustKey = i;// 未填写的键
                        toggleMust = false;
                        break;
                    }
                }
            }
            // 如果有必填项
            if (!toggleMust && !!toggleMustKey && !!mustObj[toggleMustKey] && mustObj.hasAlert ) {
                Util.BootstrapDialogAlert(mustObj[toggleMustKey]);
            }
            return toggleMust;
        },
        // 给字段加锁不可修改（置灰）
        // ep: EditUtil.lockField($(".search_form .Approved_Show .lock"))
        lockField(DomList){
            DomList.each((i,item)=>{
                if( $(item)[0].nodeName == 'TD' ||  $(item)[0].nodeName == 'TABLE' ){
                    $(item).find("input").prop("disabled",true)
                    $(item).find("textarea").prop("disabled",true)
                    $(item).find(".dropdown_box").addClass("readonly")
                    if( $(item).find("input").parents(".iconInputGroup").length > 0 ){
                        $(item).find("input").parents(".iconInputGroup").addClass("readonly");
                    }
                }else if( $(item)[0].nodeName == 'INPUT' ||  $(item)[0].nodeName == 'TEXTAREA' ){
                    $(item).prop("disabled",true)
                    if( $(item).parents(".iconInputGroup").length > 0 ){
                        $(item).parents(".iconInputGroup").addClass("readonly");
                    }
                }else if( $(item).hasClass("dropdown_box") ){
                    $(item).addClass("readonly")
                }
            });
        }
    }
}
EditUtilFn();

/**
 * 添加loading
 */
function addLoading() {
    if ($("#loadModel").length == 0) {
        let loadingHtml = `
        <!-- 圆点转圈loading -->
        <div class="modal fade" id="loadModel" data-backdrop="static" style="background:rgba(255,255,255,0);">
            <div class="modal-dialog">
                <div class="load4">
                    <div class="loader"></div>
                </div>
            </div>
        </div>`;
        $("body").prepend(loadingHtml);
    }
}
// addLoading();
if (!!Date) {
    // 日期格式化
    Date.prototype.format = function (fmt) {
        //author: meizz 
        var o = {
            "M+": this.getMonth() + 1, //月份 
            "d+": this.getDate(), //日 
            "h+": this.getHours(), //小时 
            "m+": this.getMinutes(), //分 
            "s+": this.getSeconds(), //秒 
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
            "S": this.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt;

    }
}
// 金额显示
$("body").on("focus","input[data-type=fee]",function(){
    $(this).unbind("focus");
    let val = !!$(this).val() ? Number($(this).val().trim().replace(/\,/g,"")) : "";
    $(this).attr("type","number");
    $(this).val( val );
});
$("body").on("blur","input[data-type=fee]",function(){
    $(this).unbind("blur");
    let Fval = $(this).val().trim().replace(/\,/g,"")
    let val = !!$(this).val() ? Util.FormatThousand(Fval) : "";
    $(this).attr("type","text");
    $(this).val( val ).attr("data-value",Fval);
});

//tab切换 
Util.PeriodChange();